Sha256: 9be4a79235a69cf30f1de42dc5916f7b6307141003dfcbaa1b9f1356ab7fcfd4
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module BELParser module Expression module Model class Term include Comparable attr_accessor :function, :arguments def initialize(function, *arguments) unless function && function.is_a?(BELParser::Language::Function) raise( ArgumentError, %(function: expected Function, actual #{function.class})) end @function = function @arguments = (arguments ||= []).flatten end def <<(item) @arguments << item end def valid? # TODO Use expression validator. end def hash [@function, @arguments].hash end def ==(other) return false if other == nil @function == other.function && @arguments == other.arguments end alias :eql? :'==' def to_s(form = :short) args = [@arguments].flatten.map { |arg| arg.to_s(form) }.join(',') case form when :short "#{@function.short}(#{args})" when :long "#{@function.long}(#{args})" else nil end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bel_parser-1.0.0.alpha.28-java | lib/bel_parser/expression/model/term.rb |
bel_parser-1.0.0.alpha.28 | lib/bel_parser/expression/model/term.rb |