Class: CommaParty::ParseBody
- Inherits:
-
Object
- Object
- CommaParty::ParseBody
- Defined in:
- lib/commaparty/parse_body.rb
Instance Method Summary collapse
- #body ⇒ Object
- #call ⇒ Object
-
#initialize(element) ⇒ ParseBody
constructor
A new instance of ParseBody.
- #nested? ⇒ Boolean
Constructor Details
#initialize(element) ⇒ ParseBody
Returns a new instance of ParseBody.
4 5 6 |
# File 'lib/commaparty/parse_body.rb', line 4 def initialize(element) @element = element end |
Instance Method Details
#body ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/commaparty/parse_body.rb', line 16 def body @body ||= if @element[1].is_a?(Hash) @element[2..-1] else @element[1..-1] end end |
#call ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/commaparty/parse_body.rb', line 8 def call if nested? body.flatten(1) else body end end |
#nested? ⇒ Boolean
25 26 27 |
# File 'lib/commaparty/parse_body.rb', line 25 def nested? body[0].is_a?(Array) && !body[0][0].is_a?(Symbol) end |