Class: Slimi::Filters::EndInserter::Expression
- Inherits:
-
Object
- Object
- Slimi::Filters::EndInserter::Expression
- Defined in:
- lib/slimi/filters/end_inserter.rb
Constant Summary collapse
- IF_REGEXP =
/\A(if|begin|unless|else|elsif|when|rescue|ensure)\b|\bdo\s*(\|[^|]*\|)?\s*$/.freeze
- ELSE_REGEXP =
/\A(else|elsif|when|rescue|ensure)\b/.freeze
- END_REGEXP =
/\Aend\b/.freeze
Instance Method Summary collapse
- #control? ⇒ Boolean
- #else? ⇒ Boolean
- #end? ⇒ Boolean
- #if? ⇒ Boolean
-
#initialize(expression) ⇒ Expression
constructor
A new instance of Expression.
- #newline? ⇒ Boolean
Constructor Details
#initialize(expression) ⇒ Expression
Returns a new instance of Expression.
46 47 48 |
# File 'lib/slimi/filters/end_inserter.rb', line 46 def initialize(expression) @expression = expression end |
Instance Method Details
#control? ⇒ Boolean
51 52 53 |
# File 'lib/slimi/filters/end_inserter.rb', line 51 def control? @expression[0] == :slimi && @expression[1] == :control end |
#else? ⇒ Boolean
61 62 63 |
# File 'lib/slimi/filters/end_inserter.rb', line 61 def else? @expression[2].match?(ELSE_REGEXP) end |
#end? ⇒ Boolean
66 67 68 |
# File 'lib/slimi/filters/end_inserter.rb', line 66 def end? @expression[2].match?(END_REGEXP) end |
#if? ⇒ Boolean
56 57 58 |
# File 'lib/slimi/filters/end_inserter.rb', line 56 def if? @expression[2].match?(IF_REGEXP) end |
#newline? ⇒ Boolean
71 72 73 |
# File 'lib/slimi/filters/end_inserter.rb', line 71 def newline? @expression[0] == :newline end |