Sha256: c5973bd52268d29b132d9918554a48d443f9763675f3dcefd544be31f3d963f2

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

module Danica
  class Wrapper::Variable
    include ActiveModel::Model
    include BaseOperations
    include Common

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

    default_value :priority, 10
    default_value :is_grouped?, false

    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

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.4.0 lib/danica/wrapper/variable.rb
danica-2.3.1 lib/danica/wrapper/variable.rb
danica-2.3.0 lib/danica/wrapper/variable.rb