Class: Nydp::Symbol
Direct Known Subclasses
Defined Under Namespace
Classes: Unbound
Constant Summary collapse
- EMPTY =
:""
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #>(other) ⇒ Object
- #assign(value, _ = nil) ⇒ Object
- #execute(vm) ⇒ Object
-
#hash ⇒ Object
can’t cache this, it seems to break when unmarshalling.
-
#initialize(name) ⇒ Symbol
constructor
A new instance of Symbol.
- #inspect ⇒ Object
- #is?(nm) ⇒ Boolean
- #nydp_type ⇒ Object
- #to_ruby ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
- #untidy(str) ⇒ Object
- #value(context = nil) ⇒ Object
Constructor Details
#initialize(name) ⇒ Symbol
Returns a new instance of Symbol.
10 11 12 13 14 |
# File 'lib/nydp/symbol.rb', line 10 def initialize name name = name.to_s @name = name.to_sym @inspection = "|#{name.gsub(/\|/, '\|')}|" if untidy(name) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/nydp/symbol.rb', line 4 def name @name end |
Class Method Details
.find(name, ns) ⇒ Object
38 |
# File 'lib/nydp/symbol.rb', line 38 def self.find name, ns ; ns[name.to_sym] ; end |
.mk(name, ns) ⇒ Object
33 34 35 36 |
# File 'lib/nydp/symbol.rb', line 33 def self.mk name, ns name = name.to_s.to_sym ns[name] ||= new(name) end |
.new(name) ⇒ Object
6 7 8 |
# File 'lib/nydp/symbol.rb', line 6 def self.new name special(name.to_s.to_sym) || super end |
Instance Method Details
#<(other) ⇒ Object
47 |
# File 'lib/nydp/symbol.rb', line 47 def < other ; self.name < other.name ; end |
#<=>(other) ⇒ Object
48 |
# File 'lib/nydp/symbol.rb', line 48 def <=> other ; self.name <=> other.name ; end |
#==(other) ⇒ Object Also known as: eql?
52 53 54 |
# File 'lib/nydp/symbol.rb', line 52 def == other other.is_a?(Nydp::Symbol) && (self.name == other.name) end |
#>(other) ⇒ Object
46 |
# File 'lib/nydp/symbol.rb', line 46 def > other ; self.name > other.name ; end |
#assign(value, _ = nil) ⇒ Object
49 |
# File 'lib/nydp/symbol.rb', line 49 def assign value, _=nil ; @value = value ; end |
#execute(vm) ⇒ Object
50 |
# File 'lib/nydp/symbol.rb', line 50 def execute vm ; vm.push_arg self.value ; end |
#hash ⇒ Object
can’t cache this, it seems to break when unmarshalling
16 |
# File 'lib/nydp/symbol.rb', line 16 def hash ; name.hash ; end |
#inspect ⇒ Object
41 |
# File 'lib/nydp/symbol.rb', line 41 def inspect ; @inspection || name.to_s ; end |
#is?(nm) ⇒ Boolean
45 |
# File 'lib/nydp/symbol.rb', line 45 def is? nm ; self.name == nm.to_sym ; end |
#nydp_type ⇒ Object
40 |
# File 'lib/nydp/symbol.rb', line 40 def nydp_type ; :symbol ; end |
#to_ruby ⇒ Object
44 |
# File 'lib/nydp/symbol.rb', line 44 def to_ruby ; to_sym ; end |
#to_s ⇒ Object
42 |
# File 'lib/nydp/symbol.rb', line 42 def to_s ; name.to_s ; end |
#to_sym ⇒ Object
43 |
# File 'lib/nydp/symbol.rb', line 43 def to_sym ; name ; end |
#untidy(str) ⇒ Object
18 19 20 |
# File 'lib/nydp/symbol.rb', line 18 def untidy str (str == "") || (str == nil) || (str =~ /[\s\|,\(\)"]/) end |