Class: Chemtrail::SectionPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/chemtrail/section_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, entries) ⇒ SectionPresenter

Returns a new instance of SectionPresenter.



4
5
6
7
# File 'lib/chemtrail/section_presenter.rb', line 4

def initialize(name, entries)
  @name = name
  @entries = entries
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



2
3
4
# File 'lib/chemtrail/section_presenter.rb', line 2

def entries
  @entries
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/chemtrail/section_presenter.rb', line 2

def name
  @name
end

Instance Method Details

#to_hashObject



9
10
11
12
13
14
15
# File 'lib/chemtrail/section_presenter.rb', line 9

def to_hash
  if entries.empty?
    {}
  else
    {name => entries.map(&:to_hash).reduce(Hash.new, :merge)}
  end
end