Class: ODDB::State::Feedbacks::ItemWrapper

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
src/state/feedbacks.rb

Constant Summary

INDEX_STEP =
10

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (ItemWrapper) initialize(item)

A new instance of ItemWrapper



18
19
20
21
22
# File 'src/state/feedbacks.rb', line 18

def initialize(item)
  @item = item
  @index = 0
  super
end

Instance Attribute Details

- (Object) current_feedback



23
24
25
26
27
28
29
# File 'src/state/feedbacks.rb', line 23

def current_feedback
  @current_feedback or begin
    fb = Persistence::CreateItem.new(Persistence::Pointer.new(:feedback))
    fb.carry(:item, @item)
    @current_feedback = fb
  end
end

- (Object) index

Returns the value of attribute index



16
17
18
# File 'src/state/feedbacks.rb', line 16

def index
  @index
end

- (Object) item (readonly)

Returns the value of attribute item



17
18
19
# File 'src/state/feedbacks.rb', line 17

def item
  @item
end

Instance Method Details

- (Object) feedback_count



33
34
35
# File 'src/state/feedbacks.rb', line 33

def 
  @item.feedbacks.size
end

- (Object) feedback_list



30
31
32
# File 'src/state/feedbacks.rb', line 30

def 
  @item.feedbacks[@index, INDEX_STEP]
end

- (Boolean) has_next?

Returns:

  • (Boolean)


36
37
38
# File 'src/state/feedbacks.rb', line 36

def has_next?
   > next_index
end

- (Boolean) has_prev?

Returns:

  • (Boolean)


39
40
41
# File 'src/state/feedbacks.rb', line 39

def has_prev?
  @index > 0
end

- (Object) next_index



42
43
44
# File 'src/state/feedbacks.rb', line 42

def next_index
  @index + INDEX_STEP
end

- (Object) prev_index



45
46
47
# File 'src/state/feedbacks.rb', line 45

def prev_index
  @index - INDEX_STEP
end