Class: Postsvg::Model::Literals::Procedure

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/postsvg/model/literals/procedure.rb

Overview

Procedure body: { ... }. Carries the inner token stream as a list of literal/operator nodes. Procedures are not executed by the parser; the renderer descends into them on InvokeProcedure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body = []) ⇒ Procedure

Returns a new instance of Procedure.



14
15
16
17
# File 'lib/postsvg/model/literals/procedure.rb', line 14

def initialize(body = [])
  @body = body.freeze
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



12
13
14
# File 'lib/postsvg/model/literals/procedure.rb', line 12

def body
  @body
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



30
31
32
# File 'lib/postsvg/model/literals/procedure.rb', line 30

def ==(other)
  other.is_a?(Procedure) && other.body == @body
end

#accept(visitor, ctx) ⇒ Object



26
27
28
# File 'lib/postsvg/model/literals/procedure.rb', line 26

def accept(visitor, ctx)
  visitor.visit_procedure(self, ctx)
end

#each(&block) ⇒ Object



19
20
21
# File 'lib/postsvg/model/literals/procedure.rb', line 19

def each(&block)
  @body.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


24
# File 'lib/postsvg/model/literals/procedure.rb', line 24

def empty? = @body.empty?

#hashObject



35
36
37
# File 'lib/postsvg/model/literals/procedure.rb', line 35

def hash
  @body.hash
end

#lengthObject



23
# File 'lib/postsvg/model/literals/procedure.rb', line 23

def length = @body.length