Class: Postsvg::Model::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/postsvg/model/program.rb

Overview

Top-level program node. Carries DSC header (BoundingBox, Title, etc.) and the body — an ordered list of statements, each either a literal (Number/Name/String/Array/Procedure/Dictionary) or an Operator instance.

Defined Under Namespace

Classes: Header

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header: Header.new, body: []) ⇒ Program

Returns a new instance of Program.



12
13
14
15
16
# File 'lib/postsvg/model/program.rb', line 12

def initialize(header: Header.new, body: [])
  @header = header
  @body = body
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/postsvg/model/program.rb', line 10

def body
  @body
end

#headerObject (readonly)

Returns the value of attribute header.



10
11
12
# File 'lib/postsvg/model/program.rb', line 10

def header
  @header
end

Instance Method Details

#append(statement) ⇒ Object



22
23
24
# File 'lib/postsvg/model/program.rb', line 22

def append(statement)
  Program.new(header: @header, body: @body + [statement])
end

#concat(statements) ⇒ Object



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

def concat(statements)
  Program.new(header: @header, body: @body + statements)
end

#with(header: nil, body: nil) ⇒ Object



18
19
20
# File 'lib/postsvg/model/program.rb', line 18

def with(header: nil, body: nil)
  Program.new(header: header || @header, body: body || @body)
end