alchemist 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/alchemist.rb +9 -1
  3. metadata +3 -5
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ PKG_FILES = %w(Rakefile) +
6
6
 
7
7
  gem_spec = Gem::Specification.new do |gem_spec|
8
8
  gem_spec.name = 'alchemist'
9
- gem_spec.version = '0.0.6'
9
+ gem_spec.version = '0.0.7'
10
10
  gem_spec.summary = 'Conversions... like you\'ve never seen them before!'
11
11
  gem_spec.description = 'Conversions... like you\'ve never seen them before!!'
12
12
  gem_spec.email = 'matt@toastyapps.com'
data/lib/alchemist.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  module Alchemist
2
+ @use_si = false
3
+ class << self
4
+ attr_accessor :use_si
5
+ end
6
+
2
7
  @@si_units = %w[m meter metre meters metres liter litre litres liters l L farad farads F coulombs C gray grays Gy siemen siemens S mhos mho ohm ohms volt volts V ]
3
8
  @@si_units += %w[joule joules J newton newtons N lux lx henry henrys H b B bits bytes bit byte lumen lumens lm candela candelas cd]
4
9
  @@si_units += %w[tesla teslas T gauss Gs G gram gramme grams grammes g watt watts W pascal pascals Pa]
@@ -153,7 +158,7 @@ module Alchemist
153
158
  },
154
159
  :information_storage => {
155
160
  :bit => 1.0, :bits => 1.0, :b => 1.0,
156
- :byte => 8.0, :bytes => 8.0,
161
+ :byte => 8.0, :bytes => 8.0, :B => 8.0,
157
162
  :nibbles => 4.0, :nybbles => 4.0
158
163
  },
159
164
  :luminous_flux => {
@@ -392,6 +397,9 @@ module Alchemist
392
397
  def self.parse_prefix(unit)
393
398
  @@british_standard_unit_prefixes.each do |prefix, value|
394
399
  if unit.to_s =~ /^#{prefix}.+/ && @@si_units.include?(unit.to_s.gsub(/^#{prefix}/,''))
400
+ if !(Conversions[ unit.to_s.gsub(/^#{prefix}/,'').to_sym ] & [ :information_storage ]).empty? && !@use_si && value >= 1000.0
401
+ value = 2 ** (10 * (Math.log(value) / Math.log(10)) / 3)
402
+ end
395
403
  return [value, unit.to_s.gsub(/^#{prefix}/,'').to_sym]
396
404
  end
397
405
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-06 00:00:00 -05:00
12
+ date: 2009-11-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -26,8 +26,6 @@ files:
26
26
  - lib/alchemist.rb
27
27
  has_rdoc: true
28
28
  homepage: http://github.com/toastyapps/alchemist
29
- licenses: []
30
-
31
29
  post_install_message:
32
30
  rdoc_options: []
33
31
 
@@ -48,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
46
  requirements: []
49
47
 
50
48
  rubyforge_project:
51
- rubygems_version: 1.3.4
49
+ rubygems_version: 1.3.1
52
50
  signing_key:
53
51
  specification_version: 3
54
52
  summary: Conversions... like you've never seen them before!