Class: Quantify::Unit::Prefix::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/quantify/unit/prefix/base_prefix.rb

Direct Known Subclasses

NonSI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



19
20
21
22
23
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 19

def initialize(options)
  @symbol = options[:symbol].remove_underscores
  @factor = options[:factor].to_f
  @name = options[:name].remove_underscores.downcase
end

Instance Attribute Details

#factorObject (readonly)

Returns the value of attribute factor.



17
18
19
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 17

def factor
  @factor
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 17

def name
  @name
end

#symbolObject (readonly)

Returns the value of attribute symbol.



17
18
19
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 17

def symbol
  @symbol
end

Class Method Details

.configure(&block) ⇒ Object



13
14
15
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 13

def self.configure(&block)
  self.class_eval(&block) if block
end

.load(options) ⇒ Object



7
8
9
10
11
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 7

def self.load(options)
  if options.is_a? Hash
    Prefix.prefixes << self.new(options)
  end
end

Instance Method Details

#is_non_si_prefix?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 29

def is_non_si_prefix?
  self.is_a?(NonSI)
end

#is_si_prefix?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 25

def is_si_prefix?
  self.is_a? SI
end

#labelObject



33
34
35
# File 'lib/quantify/unit/prefix/base_prefix.rb', line 33

def label
  symbol
end