Sha256: 0a3c302dbb92061edbc0046f73b6247f7d2883380c87d4682df7a86c0850a435

Contents?: true

Size: 673 Bytes

Versions: 7

Compression:

Stored size: 673 Bytes

Contents

module BEL
  module Model
    class Term
      include Comparable
      attr_accessor :fx, :arguments, :signature

      def initialize(fx, *arguments)
        @fx = fx
        @arguments = (arguments ||= []).flatten
      end

      def <<(item)
        @arguments << item
      end

      def hash
        [@fx, @arguments].hash
      end

      def ==(other)
        return false if other == nil
        @fx == other.fx && @arguments == other.arguments
      end
      alias_method :eql?, :'=='

      def to_bel
        arguments = [@arguments].flatten.map(&:to_bel).join(',') 
        "#@fx(#{arguments})"
      end
      alias_method :to_s, :to_bel
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bel-0.3.1-x64-mingw32 lib/bel/evidence_model/bel_term.rb
bel-0.3.1-x86-mingw32 lib/bel/evidence_model/bel_term.rb
bel-0.3.1 lib/bel/evidence_model/bel_term.rb
bel-0.3.0-x86-mingw32 lib/bel/evidence_model/bel_term.rb
bel-0.3.0-x64-mingw32 lib/bel/evidence_model/bel_term.rb
bel-0.3.0 lib/bel/evidence_model/bel_term.rb
bel-0.3.0.beta6 lib/bel/evidence_model/bel_term.rb