Class: Nydp::Literal

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression) ⇒ Literal

Returns a new instance of Literal.



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

def initialize expression
  @expression = expression
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



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

def expression
  @expression
end

Class Method Details

.build(expression, bindings) ⇒ Object



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

def self.build expression, bindings
  new expression
end

Instance Method Details

#<(other) ⇒ Object



33
34
35
# File 'lib/nydp/literal.rb', line 33

def < other
  other > expression
end

#==(other) ⇒ Object



37
38
39
# File 'lib/nydp/literal.rb', line 37

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

#>(other) ⇒ Object



29
30
31
# File 'lib/nydp/literal.rb', line 29

def > other
  other < expression
end

#coerce(_) ⇒ Object



25
26
27
# File 'lib/nydp/literal.rb', line 25

def coerce _
  [_, expression]
end

#execute(vm) ⇒ Object



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

def execute vm
  vm.push_arg expression
end

#inspectObject



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

def inspect   ; @expression.inspect ; end

#lisp_applyObject



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

def lisp_apply
  expression
end

#nydp_typeObject



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

def nydp_type ; :literal            ; end

#to_sObject



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

def to_s      ; @expression.to_s    ; end