Class: Atomy::Grammar::AST::Postfix

Inherits:
Node show all
Defined in:
lib/atomy/grammar.rb,
lib/atomy/node/meta.rb,
lib/atomy/node/pretty.rb,
lib/atomy/node/equality.rb,
lib/atomy/node/constructable.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#accept, #attributes, basename, #children

Constructor Details

#initialize(node, operator) ⇒ Postfix

Returns a new instance of Postfix.



115
116
117
118
# File 'lib/atomy/grammar.rb', line 115

def initialize(node, operator)
  @node = node
  @operator = operator
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



119
120
121
# File 'lib/atomy/grammar.rb', line 119

def node
  @node
end

#operatorObject (readonly)

Returns the value of attribute operator.



120
121
122
# File 'lib/atomy/grammar.rb', line 120

def operator
  @operator
end

Instance Method Details

#==(other) ⇒ Object



64
65
66
67
68
# File 'lib/atomy/node/equality.rb', line 64

def ==(other)
  super || other.is_a?(self.class) && \
    @operator == other.operator && \
    @node == other.node
end

#construct(gen) ⇒ Object



97
98
99
100
101
102
# File 'lib/atomy/node/constructable.rb', line 97

def construct(gen)
  push_node(gen, :Postfix)
  @node.construct(gen)
  gen.push_literal(@operator)
  gen.send(:new, 2)
end

#each_attribute {|:operator, @operator| ... } ⇒ Object

Yields:



131
132
133
# File 'lib/atomy/node/meta.rb', line 131

def each_attribute
  yield :operator, @operator
end

#each_child {|:node, @node| ... } ⇒ Object

Yields:



135
136
137
# File 'lib/atomy/node/meta.rb', line 135

def each_child
  yield :node, @node
end

#throughObject



139
140
141
# File 'lib/atomy/node/meta.rb', line 139

def through
  self.class.new(yield(@node), @operator)
end

#to_sObject



60
61
62
# File 'lib/atomy/node/pretty.rb', line 60

def to_s
  "#@node#@operator"
end