Sha256: 0ff7721d12b05d982e9d3a603e8fb9c44c53a429a6752dc3d2a3299df51fc14d

Contents?: true

Size: 1.96 KB

Versions: 11

Compression:

Stored size: 1.96 KB

Contents

module BELParser
  module Language
    # Relationship allows you to describe the type of BEL Relationship.
    #
    # BEL Relationships represent an interaction between a subject and object
    # in the BEL expression.
    module Relationship
      def short
        raise NotImplementedError, "#{__method__} is not implemented."
      end

      def long
        raise NotImplementedError, "#{__method__} is not implemented."
      end

      def description
        raise NotImplementedError, "#{__method__} is not implemented."
      end

      # Indicates whether this relationship is deprecated. Override in your
      # relationship to mark as deprecated.
      #
      # @return [Boolean] false
      def deprecated?
        false
      end

      def causal?
        false
      end

      def correlative?
        false
      end

      def decreasing?
        false
      end

      def direct?
        false
      end

      def directed?
        false
      end

      def genomic?
        false
      end

      def increasing?
        false
      end

      def indirect?
        false
      end

      def injected?
        false
      end

      def listable?
        false
      end

      def self?
        false
      end

      def ==(other)
        return true if equal?(other)
        return false if other.nil?
        short == other || long == other
      end

      def to_sym(form = :short)
        _form_value(form)
      end

      def to_s(form = :short)
        value = _form_value(form)
        return nil unless value
        value.to_s
      end

      def to_h(hash = {})
        hash.merge!({
          'short'       => short,
          'long'        => long,
          'description' => description
        })
      end

      def =~(regexp)
        short =~ regexp || long =~ regexp
      end

      private

      def _form_value(form = :short)
        case form
        when :short
          short
        when :long
          long
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bel_parser-1.1.6-java lib/bel_parser/language/relationship.rb
bel_parser-1.1.6 lib/bel_parser/language/relationship.rb
bel_parser-1.1.5 lib/bel_parser/language/relationship.rb
bel_parser-1.1.4-java lib/bel_parser/language/relationship.rb
bel_parser-1.1.4 lib/bel_parser/language/relationship.rb
bel_parser-1.1.3-java lib/bel_parser/language/relationship.rb
bel_parser-1.1.3 lib/bel_parser/language/relationship.rb
bel_parser-1.1.2-java lib/bel_parser/language/relationship.rb
bel_parser-1.1.2 lib/bel_parser/language/relationship.rb
bel_parser-1.1.1-java lib/bel_parser/language/relationship.rb
bel_parser-1.1.1 lib/bel_parser/language/relationship.rb