Class: Nydp::Literal

Inherits:
Object show all
Includes:
Helper
Defined in:
lib/nydp/literal.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

#cons, #list, #literal?, #pair?, #sig, #sym, #sym?

Methods included from Converter

#n2r, #r2n

Constructor Details

#initialize(expression) ⇒ Literal

Returns a new instance of Literal.



6
7
8
# File 'lib/nydp/literal.rb', line 6

def initialize expression
  @expression = expression
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



4
5
6
# File 'lib/nydp/literal.rb', line 4

def expression
  @expression
end

Class Method Details

.build(expression, bindings) ⇒ Object



10
11
12
# File 'lib/nydp/literal.rb', line 10

def self.build expression, bindings
  new expression
end

Instance Method Details

#<(other) ⇒ Object



31
32
33
# File 'lib/nydp/literal.rb', line 31

def < other
  other > expression
end

#==(other) ⇒ Object



35
36
37
# File 'lib/nydp/literal.rb', line 35

def == other
  other.is_a?(Literal) && (self.expression == other.expression)
end

#>(other) ⇒ Object



27
28
29
# File 'lib/nydp/literal.rb', line 27

def > other
  other < expression
end

#coerce(_) ⇒ Object



23
24
25
# File 'lib/nydp/literal.rb', line 23

def coerce _
  [_, expression]
end

#execute(vm) ⇒ Object



14
15
16
# File 'lib/nydp/literal.rb', line 14

def execute vm
  vm.push_arg expression
end

#inspectObject



19
# File 'lib/nydp/literal.rb', line 19

def inspect   ; @expression.inspect ; end

#nydp_typeObject



18
# File 'lib/nydp/literal.rb', line 18

def nydp_type ; :literal            ; end

#to_rubyObject



21
# File 'lib/nydp/literal.rb', line 21

def to_ruby   ; n2r @expression     ; end

#to_sObject



20
# File 'lib/nydp/literal.rb', line 20

def to_s      ; @expression.to_s    ; end