Class: Postscript::Model::Literals::Name
- Inherits:
-
Object
- Object
- Postscript::Model::Literals::Name
- Defined in:
- lib/postscript/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
-
#literal ⇒ Object
readonly
Returns the value of attribute literal.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #accept(visitor, ctx) ⇒ Object
- #executable? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(value, literal: false) ⇒ Name
constructor
A new instance of Name.
- #literal? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(value, literal: false) ⇒ Name
Returns a new instance of Name.
12 13 14 15 16 |
# File 'lib/postscript/model/literals/name.rb', line 12 def initialize(value, literal: false) @value = value.to_s @literal = literal freeze end |
Instance Attribute Details
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
10 11 12 |
# File 'lib/postscript/model/literals/name.rb', line 10 def literal @literal end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/postscript/model/literals/name.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
29 30 31 |
# File 'lib/postscript/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/postscript/model/literals/name.rb', line 25 def accept(visitor, ctx) visitor.visit_name(self, ctx) end |
#executable? ⇒ Boolean
19 |
# File 'lib/postscript/model/literals/name.rb', line 19 def executable? = !literal |
#hash ⇒ Object
34 35 36 |
# File 'lib/postscript/model/literals/name.rb', line 34 def hash [value, literal].hash end |
#literal? ⇒ Boolean
18 |
# File 'lib/postscript/model/literals/name.rb', line 18 def literal? = literal |
#to_s ⇒ Object
21 22 23 |
# File 'lib/postscript/model/literals/name.rb', line 21 def to_s @value end |