Class: Postsvg::Model::Literals::Name

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

Overview

A PostScript name. literal: distinguishes /foo (literal, pushed onto the stack) from foo (executable, looked up and executed).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, literal: false) ⇒ Name

Returns a new instance of Name.



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

def initialize(value, literal: false)
  @value = value.to_s
  @literal = literal
  freeze
end

Instance Attribute Details

#literalObject (readonly)

Returns the value of attribute literal.



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

def literal
  @literal
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

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



29
30
31
# File 'lib/postsvg/model/literals/name.rb', line 29

def ==(other)
  other.is_a?(Name) && other.value == value && other.literal == literal
end

#accept(visitor, ctx) ⇒ Object



25
26
27
# File 'lib/postsvg/model/literals/name.rb', line 25

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

#executable?Boolean

Returns:

  • (Boolean)


19
# File 'lib/postsvg/model/literals/name.rb', line 19

def executable? = !literal

#hashObject



34
35
36
# File 'lib/postsvg/model/literals/name.rb', line 34

def hash
  [value, literal].hash
end

#literal?Boolean

Returns:

  • (Boolean)


18
# File 'lib/postsvg/model/literals/name.rb', line 18

def literal? = literal

#to_sObject



21
22
23
# File 'lib/postsvg/model/literals/name.rb', line 21

def to_s
  @value
end