Sha256: 8c56cc97fa79d39eb7abe981ec318ec78a265011061e6ef84d2e3e12e6e10dfd

Contents?: true

Size: 911 Bytes

Versions: 7

Compression:

Stored size: 911 Bytes

Contents

module Danica
  class Wrapper::Variable
    include BaseOperations
    include Common

    attr_accessor :value, :name, :latex, :gnu

    default_value :priority, 10
    default_value :is_grouped?, false

    def initialize(attributes={})
      attributes.each do |key, value|
        self.public_send("#{key}=", value)
      end
    end

    def to_f
      value.nil? ? raise(Exception::NotDefined) : value.to_f
    end

    def ==(other)
      return false unless other.class == self.class
      return other.value == value &&
             other.name == name &&
             other.latex == latex &&
             other.gnu == gnu
    end

    def to_tex
      return value.to_tex if value
      (latex || name).to_s
    end

    def to_gnu
      return value.to_gnu if value
      (gnu || name).to_s
    end

    def value=(value)
      @value = value.is_a?(Numeric) ? number(value) : value
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
danica-2.6.0 lib/danica/wrapper/variable.rb
danica-2.5.1 lib/danica/wrapper/variable.rb
danica-2.5.0 lib/danica/wrapper/variable.rb
danica-2.4.4 lib/danica/wrapper/variable.rb
danica-2.4.3 lib/danica/wrapper/variable.rb
danica-2.4.2 lib/danica/wrapper/variable.rb
danica-2.4.1 lib/danica/wrapper/variable.rb