Sha256: 4963ca273a1cc7abc3fa31afe037731adb4bda497e743b89d3b69e3e24d0ee73

Contents?: true

Size: 513 Bytes

Versions: 1

Compression:

Stored size: 513 Bytes

Contents

module Danica
  class Variable
    include ActiveModel::Model
    attr_accessor :value, :name, :latex, :gnu

    def to_f
      value.nil? ? raise(Exception::NotDefined) : value.to_f
    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 valued?
      value.present?
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danica-1.0.0 lib/danica/variable.rb