Class: BEL::Language::F

Inherits:
Object
  • Object
show all
Defined in:
lib/bel/language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(func_return, var = false) ⇒ F

Returns a new instance of F.



43
44
45
46
# File 'lib/bel/language.rb', line 43

def initialize(func_return, var=false)
  @func_return = func_return
  @var = var
end

Instance Attribute Details

#func_returnObject (readonly)

Returns the value of attribute func_return.



42
43
44
# File 'lib/bel/language.rb', line 42

def func_return
  @func_return
end

#varObject (readonly)

Returns the value of attribute var.



42
43
44
# File 'lib/bel/language.rb', line 42

def var
  @var
end

Instance Method Details

#<=>(other) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/bel/language.rb', line 60

def <=>(other)
  return 1 if @var ^ other.var

  tree = FUNCTION_TYPES[@func_return]
  return -1 if not tree.include?(other.func_return)
  -(tree.index(@func_return) <=> tree.index(other.func_return))
end

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



48
49
50
51
52
# File 'lib/bel/language.rb', line 48

def ==(other)
  return false if not other.respond_to? :func_return

  @func_return == other.func_return and @var == other.var
end

#hashObject



56
57
58
# File 'lib/bel/language.rb', line 56

def hash
  [@func_return, @var].hash
end

#to_sObject



68
69
70
# File 'lib/bel/language.rb', line 68

def to_s
  "F:#{@func_return}#{'...' if @var}"
end