Class: Chemtrail::SectionPresenter
- Inherits:
-
Object
- Object
- Chemtrail::SectionPresenter
- Defined in:
- lib/chemtrail/section_presenter.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, entries) ⇒ SectionPresenter
constructor
A new instance of SectionPresenter.
- #to_hash ⇒ Object
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
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
2 3 4 |
# File 'lib/chemtrail/section_presenter.rb', line 2 def entries @entries end |
#name ⇒ Object (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_hash ⇒ Object
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 |