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.



180
181
182
183
# File 'lib/bel/language.rb', line 180

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.



179
180
181
# File 'lib/bel/language.rb', line 179

def func_return
  @func_return
end

#varObject (readonly)

Returns the value of attribute var.



179
180
181
# File 'lib/bel/language.rb', line 179

def var
  @var
end

Instance Method Details

#<=>(other) ⇒ Object



197
198
199
200
201
202
203
# File 'lib/bel/language.rb', line 197

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?



185
186
187
188
189
# File 'lib/bel/language.rb', line 185

def ==(other)
  return false if other == nil
  return false if not other.respond_to? :func_return
  @func_return == other.func_return and @var == other.var
end

#hashObject



193
194
195
# File 'lib/bel/language.rb', line 193

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

#to_sObject



205
206
207
# File 'lib/bel/language.rb', line 205

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