Class: Habaki::SupportsExpression

Inherits:
Node
  • Object
show all
Defined in:
lib/habaki/supports_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#to_s

Constructor Details

#initializeSupportsExpression

Returns a new instance of SupportsExpression.



10
11
12
# File 'lib/habaki/supports_rule.rb', line 10

def initialize
  @expressions = []
end

Instance Attribute Details

#declarationDeclaration

Returns:



8
9
10
# File 'lib/habaki/supports_rule.rb', line 8

def declaration
  @declaration
end

#expressionsArray<SupportsExpression>

Returns:



6
7
8
# File 'lib/habaki/supports_rule.rb', line 6

def expressions
  @expressions
end

#operationSymbol

Returns:

  • (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

Parameters:

Returns:



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