Sha256: af3cdd25434b6277b06cccad063d8dedf8a07ff5041566683d8e4b556502f3b0
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
require 'bel_parser/quoting' module BELParser module Expression module Model class Parameter include BELParser::Quoting include Comparable attr_accessor :namespace, :value def initialize(namespace, value) raise(ArgumentError, 'value is nil') unless value unless namespace.nil? || namespace.is_a?(Namespace) raise( ArgumentError, "namespace: expected nil or Namespace, actual #{namespace.class}") end @namespace = namespace @value = value end def valid? return false unless @value return true unless @namespace !@namespace[@value].nil? end def <=>(other) namespace_compare = @namespace <=> other.namespace if namespace_compare == 0 @value <=> other.value else namespace_compare end end def hash [@namespace, @value].hash end def ==(other) return false if other == nil @namespace == other.namespace && @value == other.value end alias_method :eql?, :'==' def to_s(_) if @namespace prefix = "#{@namespace.keyword}:" else prefix = '' end %Q{#{prefix}#{quote_if_needed(@value)}} 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/parameter.rb |
bel_parser-1.0.0.alpha.28 | lib/bel_parser/expression/model/parameter.rb |