Skip to content

Commit

Permalink
Created repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Dec 29, 2009
0 parents commit 27c2eaf
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env ruby -rubygems
# -*- encoding: utf-8 -*-

GEMSPEC = Gem::Specification.new do |gem|
gem.version = File.read('VERSION').chomp
gem.date = File.mtime('VERSION').strftime('%Y-%m-%d')

gem.name = 'quantity'
gem.homepage = 'http://quantity.rubyforge.org/'
gem.license = 'Public Domain' if gem.respond_to?(:license=)
gem.summary = '...'
gem.description = '...'
gem.rubyforge_project = 'quantity'

gem.authors = ['Ben Lavender', 'Arto Bendiken']
gem.email = 'blavender@gmail.com'

gem.platform = Gem::Platform::RUBY
gem.files = %w(AUTHORS README UNLICENSE VERSION) + Dir.glob('lib/**/*.rb')
gem.bindir = %q(bin)
gem.executables = %w()
gem.default_executable = gem.executables.first
gem.require_paths = %w(lib)
gem.extensions = %w()
gem.test_files = %w()
gem.has_rdoc = false

gem.required_ruby_version = '>= 1.8.2'
gem.requirements = []
gem.add_development_dependency 'rspec', '>= 1.2.9'
gem.add_development_dependency 'yard' , '>= 0.5.2'
gem.post_install_message = nil
end
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
.tmp
.yardoc
pkg
tmp
Empty file added .yardopts
Empty file.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Ben Lavender <blavender@gmail.com> (Lead developer)
* Arto Bendiken <arto.bendiken@gmail.com> (Contributions)
1 change: 1 addition & 0 deletions README
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Quantity.rb: Units and Quantities for Ruby
==========================================

Authors
-------

* [Ben Lavender](mailto:blavender@gmail.com) - <http://bhuga.net/>
* [Arto Bendiken](mailto:arto.bendiken@gmail.com) - <http://ar.to/>

License
-------

Quantity.rb is free and unencumbered public domain software. For more
information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'rubygems'
begin
require 'rakefile' # http://github.com/bendiken/rakefile
rescue LoadError => e
end
require 'quantity'
24 changes: 24 additions & 0 deletions UNLICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0
2 changes: 2 additions & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rdoc
yard
17 changes: 17 additions & 0 deletions lib/quantity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'quantity/version'

class Quantity
autoload :Unit, 'quantity/unit'

undef_method *(instance_methods - %w(__id__ __send__ __class__ __eval__ instance_eval inspect))

attr_reader :value
attr_reader :unit

##
# @param [Numeric] value
# @param [Unit] unit
def initialize(value, unit)
@value, @unit = value, unit
end
end
28 changes: 28 additions & 0 deletions lib/quantity/unit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Quantity
class Unit
autoload :Length, 'quantity/unit/length'
autoload :Mass, 'quantity/unit/mass'
autoload :Time, 'quantity/unit/time'
autoload :Current, 'quantity/unit/current'
autoload :Temperature, 'quantity/unit/temperature'
autoload :Luminosity, 'quantity/unit/luminosity'
autoload :Substance, 'quantity/unit/substance'

# @return [String]
attr_reader :name

alias_method :to_s, :name

##
# @param [String] name
def initialize(name = nil)
@name = name || self.class.name.split(':').last.downcase
end

##
# @return [Symbol]
def to_sym
name.to_sym
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/current.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Electric_current
class Current < Unit
# TODO
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/length.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Length
class Length < Unit
# TODO
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/luminosity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Luminous_intensity
class Luminosity < Unit
# TODO
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/mass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Mass
class Mass < Unit
# TODO
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/substance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Amount_of_substance
class Substance < Unit
# TODO
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/temperature.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Thermodynamic_temperature
class Temperature < Unit
# TODO
end
end
end
9 changes: 9 additions & 0 deletions lib/quantity/unit/time.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Quantity
class Unit
##
# @see http://en.wikipedia.org/wiki/Time
class Time < Unit
# TODO
end
end
end
19 changes: 19 additions & 0 deletions lib/quantity/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Quantity
module VERSION
MAJOR = 0
MINOR = 0
TINY = 0
EXTRA = nil

STRING = [MAJOR, MINOR, TINY].join('.')
STRING << "-#{EXTRA}" if EXTRA

##
# @return [String]
def self.to_s() STRING end

##
# @return [String]
def self.to_str() STRING end
end
end

0 comments on commit 27c2eaf

Please sign in to comment.