Class: Emmett::Section
- Inherits:
-
Struct
- Object
- Struct
- Emmett::Section
- Defined in:
- lib/emmett/document.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #groups ⇒ Object
- #groups=(value) ⇒ Object
- #singular? ⇒ Boolean
- #to_hash ⇒ Object
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
14 15 16 |
# File 'lib/emmett/document.rb', line 14 def name @name end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/emmett/document.rb', line 28 def ==(other) other.is_a?(self.class) && other.name == name end |
#groups ⇒ Object
16 17 18 |
# File 'lib/emmett/document.rb', line 16 def groups @groups ||= [] end |
#groups=(value) ⇒ Object
20 21 22 |
# File 'lib/emmett/document.rb', line 20 def groups=(value) @groups = Array value end |
#singular? ⇒ Boolean
24 25 26 |
# File 'lib/emmett/document.rb', line 24 def singular? @groups.one? end |
#to_hash ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/emmett/document.rb', line 32 def to_hash { :name => name, :singular => singular?, :groups => groups.map(&:to_hash) }.tap do |result| if singular? group = groups.first.to_hash result[:endpoints] = group[:endpoints] result[:url] = group[:url] end end end |