Class: Tricle::List

Inherits:
Section show all
Defined in:
lib/tricle/presenters/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, opts = {}, &block) ⇒ List

Returns a new instance of List.



7
8
9
10
# File 'lib/tricle/presenters/list.rb', line 7

def initialize(klass, opts = {}, &block)
  @metric = klass.new(opts)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



5
6
7
# File 'lib/tricle/presenters/list.rb', line 5

def block
  @block
end

#metricObject (readonly)

Returns the value of attribute metric.



5
6
7
# File 'lib/tricle/presenters/list.rb', line 5

def metric
  @metric
end

Instance Method Details

#items_markup(start_at, end_at) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/tricle/presenters/list.rb', line 16

def items_markup(start_at, end_at)
  markup = ''
  items = self.metric.items_for_range(start_at, end_at)
  items.each do |item|
    val = self.block.call(item)
    markup << %{<tr><td class="list-item" colspan="4">#{val}</td></tr>}
  end

  markup
end

#titleObject



12
13
14
# File 'lib/tricle/presenters/list.rb', line 12

def title
  self.metric.options[:title] || self.metric.title
end