Class: Habaki::SupportsExpression
- Defined in:
- lib/habaki/supports_rule.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ SupportsExpression
constructor
A new instance of SupportsExpression.
- #read_from_katana(exp) ⇒ Object private
- #string(format = Formatter::Base.new) ⇒ String
Methods inherited from Node
Constructor Details
#initialize ⇒ SupportsExpression
Returns a new instance of SupportsExpression.
10 11 12 |
# File 'lib/habaki/supports_rule.rb', line 10 def initialize @expressions = [] end |
Instance Attribute Details
#declaration ⇒ Declaration
8 9 10 |
# File 'lib/habaki/supports_rule.rb', line 8 def declaration @declaration end |
#expressions ⇒ Array<SupportsExpression>
6 7 8 |
# File 'lib/habaki/supports_rule.rb', line 6 def expressions @expressions end |
#operation ⇒ Symbol
4 5 6 |
# File 'lib/habaki/supports_rule.rb', line 4 def operation @operation end |
Instance Method Details
#read_from_katana(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 |
# File 'lib/habaki/supports_rule.rb', line 32 def read_from_katana(exp) @operation = exp.operation exp.expressions.each do |sub_exp| @expressions << SupportsExpression.read_from_katana(sub_exp) end @declaration = Declaration.read_from_katana(exp.declaration) if exp.declaration end |
#string(format = Formatter::Base.new) ⇒ String
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/habaki/supports_rule.rb', line 16 def string(format = Formatter::Base.new) str = "" case @expressions.length when 0 if @declaration str += "(#{@declaration.string(format)})" end when 1 str += "(#{@operation == :not ? "not " : ""}" + @expressions[0].string(format) + ")" when 2 str += "#{@expressions[0].string(format)} #{@operation} #{@expressions[1].string(format)}" end str end |