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.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/bel/language.rb', line 134 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.
133 134 135 |
# File 'lib/bel/language.rb', line 133 def arguments @arguments end |
#fx ⇒ Object (readonly)
Returns the value of attribute fx.
133 134 135 |
# File 'lib/bel/language.rb', line 133 def fx @fx end |
Instance Method Details
#<=>(other) ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/bel/language.rb', line 154 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
149 150 151 152 |
# File 'lib/bel/language.rb', line 149 def ==(other) return false if other == nil @fx == other.fx && @arguments == other.arguments end |
#to_s ⇒ Object
162 163 164 165 |
# File 'lib/bel/language.rb', line 162 def to_s return_type = FUNCTIONS[@fx][:return_type] "#{@fx}(#{@arguments.map(&:to_s) * ','})#{return_type}" end |