Class: Code::Parser::Ternary
- Defined in:
- lib/code/parser/ternary.rb
Instance Method Summary collapse
- #colon ⇒ Object
- #question_mark ⇒ Object
- #root ⇒ Object
- #statement ⇒ Object
- #ternary ⇒ Object
- #whitespace ⇒ Object
- #whitespace? ⇒ Boolean
Instance Method Details
#colon ⇒ Object
26 27 28 |
# File 'lib/code/parser/ternary.rb', line 26 def colon str(":") end |
#question_mark ⇒ Object
22 23 24 |
# File 'lib/code/parser/ternary.rb', line 22 def question_mark str("?") end |
#root ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/code/parser/ternary.rb', line 30 def root ( statement.aka(:left) << ( whitespace? << question_mark << whitespace? << ternary.aka(:middle) << (whitespace? << colon << whitespace? << ternary.aka(:right)).maybe ).maybe ) .aka(:ternary) .then do |output| output[:ternary][:middle] ? output : output[:ternary][:left] end end |
#whitespace ⇒ Object
14 15 16 |
# File 'lib/code/parser/ternary.rb', line 14 def whitespace Whitespace end |
#whitespace? ⇒ Boolean
18 19 20 |
# File 'lib/code/parser/ternary.rb', line 18 def whitespace? whitespace.maybe end |