Class: BEL::Language::Signature
- Inherits:
-
Object
- Object
- BEL::Language::Signature
- Defined in:
- lib/bel/language.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#fx ⇒ Object
readonly
Returns the value of attribute fx.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(fx, *arguments) ⇒ Signature
constructor
A new instance of Signature.
- #to_s ⇒ Object
Constructor Details
#initialize(fx, *arguments) ⇒ Signature
Returns a new instance of Signature.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/bel/language.rb', line 144 def initialize(fx, *arguments) @fx = fx @arguments = arguments dup_hash = {} @arguments.each_with_index { |arg, i| (dup_hash[arg] ||= []) << i } dup_hash.keep_if { |k, v| v.length > 1 }.values.each do |v| first_arg = @arguments[v[0]] if F === first_arg replace_range = (v.first..v.last) @arguments[replace_range] = F.new(first_arg.func_return, true) end end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
143 144 145 |
# File 'lib/bel/language.rb', line 143 def arguments @arguments end |
#fx ⇒ Object (readonly)
Returns the value of attribute fx.
143 144 145 |
# File 'lib/bel/language.rb', line 143 def fx @fx end |
Instance Method Details
#<=>(other) ⇒ Object
164 165 166 167 168 169 170 |
# File 'lib/bel/language.rb', line 164 def <=>(other) return 1 if other.nil? return -1 if @fx != other.fx return -1 if @arguments.nil? and not other.nil? return 1 if not @arguments.nil? and other.nil? @arguments <=> other.arguments end |
#==(other) ⇒ Object
159 160 161 162 |
# File 'lib/bel/language.rb', line 159 def ==(other) return false if other == nil @fx == other.fx && @arguments == other.arguments end |
#to_s ⇒ Object
172 173 174 175 |
# File 'lib/bel/language.rb', line 172 def to_s return_type = FUNCTIONS[@fx][:return_type] "#{@fx}(#{@arguments.map(&:to_s) * ','})#{return_type}" end |