vanadiel-time 0.1.0 → 0.2.0

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.
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ .bundle/
2
+ bundle/
1
3
  Gemfile.lock
2
4
  doc/
3
5
  .yardoc/
data/.yardopts CHANGED
@@ -1 +1,8 @@
1
- --markup markdown --title "vanadiel-time Documentation" --protected
1
+ --markup markdown
2
+ --title "vanadiel-time Documentation"
3
+ --protected
4
+ --no-private
5
+ -
6
+ README.md
7
+ LICENSE.txt
8
+ ChangeLog.md
@@ -1,3 +1,7 @@
1
+ ### 0.2.0 / 2013-03-17
2
+
3
+ * Add compare methods (by Comparable module).
4
+
1
5
  ### 0.1.0 / 2012-09-02
2
6
 
3
7
  * Initial release:
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Yuki
1
+ Copyright (c) 2013 Yuki, a.k.a. Pasela
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -42,6 +42,6 @@ output:
42
42
 
43
43
  ## Copyright
44
44
 
45
- Copyright (c) 2012 Yuki
45
+ Copyright (c) 2013 Yuki, a.k.a. Pasela
46
46
 
47
47
  See {file:LICENSE.txt} for details.
data/Rakefile CHANGED
@@ -20,15 +20,14 @@ end
20
20
 
21
21
  require 'rake'
22
22
 
23
- require 'rubygems/tasks'
24
- Gem::Tasks.new
25
-
26
23
  require 'rspec/core/rake_task'
27
24
  RSpec::Core::RakeTask.new
28
25
 
29
26
  task :test => :spec
30
27
  task :default => :spec
31
28
 
29
+ require 'bundler/gem_tasks'
30
+
32
31
  require 'yard'
33
- YARD::Rake::YardocTask.new
32
+ YARD::Rake::YardocTask.new
34
33
  task :doc => :yard
@@ -44,8 +44,10 @@ module Vanadiel
44
44
  # A.D. 2047/10/21(Mon) 15:37:30 UTC
45
45
  # C.E. 2047/10/21(Win) 15:37:30
46
46
  class Time
47
+ include Comparable
48
+
47
49
  # vanadiel-time version
48
- VERSION = "0.1.0"
50
+ VERSION = "0.2.0"
49
51
 
50
52
  ONE_SECOND = 1000000
51
53
  ONE_MINUTE = 60 * ONE_SECOND
@@ -170,7 +172,7 @@ module Vanadiel
170
172
  # @param [Integer] vana_time microseconds as Vana'diel time
171
173
  # @return [Integer] microseconds as the Earth time
172
174
  def self.vana_to_earth(vana_time)
173
- earth = (((vana_time + ONE_YEAR) / VANA_TIME_SCALE) - DIFF_TIME)
175
+ (((vana_time + ONE_YEAR) / VANA_TIME_SCALE) - DIFF_TIME)
174
176
  end
175
177
 
176
178
  # Converts microseconds as the Earth time to microseconds as Vana'diel time from the Epoch.
@@ -422,11 +424,6 @@ module Vanadiel
422
424
  # @return [Fixnum] the hash code
423
425
  def hash; @time.hash ^ self.class.hash; end
424
426
 
425
- # Returns true if time and other time are the same time.
426
- #
427
- # @return [Boolean] true if same
428
- def ==(other); @time == other.time; end
429
-
430
427
  # Returns true if time and other time are both Vanadiel::Time objects with the same time.
431
428
  #
432
429
  # @return [Boolean] true if same
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'vanadiel/time'
5
+
6
+ describe Vanadiel::Time, ' compare methods' do
7
+ let(:earlier_time) { described_class.new(2047, 10, 20) }
8
+ let(:base_time) { described_class.new(2047, 10, 21) }
9
+ let(:later_time) { described_class.new(2047, 10, 22) }
10
+
11
+ # ==
12
+ context '== same value different object' do
13
+ let(:other) { described_class.new(2047, 10, 21) }
14
+ subject { described_class.new(2047, 10, 21) }
15
+ it { subject.==(other).should be_true }
16
+ end
17
+ context '== different values' do
18
+ let(:other) { described_class.new(2047, 10, 21) }
19
+ subject { described_class.new(2047, 10, 22) }
20
+ it { subject.==(other).should be_false }
21
+ end
22
+
23
+ # <
24
+ context '< later(greater) time' do
25
+ it { base_time.<(later_time).should be_true }
26
+ end
27
+ context '< earlier(less) time' do
28
+ it { base_time.<(earlier_time).should be_false }
29
+ end
30
+ context '< same time' do
31
+ it { base_time.<(base_time).should be_false }
32
+ end
33
+
34
+ # <=
35
+ context '<= later(greater) time' do
36
+ it { base_time.<=(later_time).should be_true }
37
+ end
38
+ context '<= earlier(less) time' do
39
+ it { base_time.<=(earlier_time).should be_false }
40
+ end
41
+ context '<= same time' do
42
+ it { base_time.<=(base_time).should be_true }
43
+ end
44
+
45
+ # >
46
+ context '> later(greater) time' do
47
+ it { base_time.>(later_time).should be_false }
48
+ end
49
+ context '> earlier(less) time' do
50
+ it { base_time.>(earlier_time).should be_true }
51
+ end
52
+ context '> same time' do
53
+ it { base_time.>(base_time).should be_false }
54
+ end
55
+
56
+ # >=
57
+ context '>= later(greater) time' do
58
+ it { base_time.>=(later_time).should be_false }
59
+ end
60
+ context '>= earlier(less) time' do
61
+ it { base_time.>=(earlier_time).should be_true }
62
+ end
63
+ context '>= same time' do
64
+ it { base_time.>=(base_time).should be_true }
65
+ end
66
+
67
+ # between?
68
+ context 'between? later(greater) time and later(greater) time' do
69
+ it { base_time.between?(later_time, later_time).should be_false }
70
+ end
71
+ context 'between? earlier(less) time and earlier(less) time' do
72
+ it { base_time.between?(earlier_time, earlier_time).should be_false }
73
+ end
74
+ context 'between? earlier(less) time and later(greater) time' do
75
+ it { base_time.between?(earlier_time, later_time).should be_true }
76
+ end
77
+ context 'between? later(greater) time and earlier(less) time' do
78
+ it { base_time.between?(later_time, earlier_time).should be_false }
79
+ end
80
+ context 'between? same time and later(greater) time' do
81
+ it { base_time.between?(base_time, later_time).should be_true }
82
+ end
83
+ context 'between? same time and earlier(less) time' do
84
+ it { base_time.between?(base_time, earlier_time).should be_false }
85
+ end
86
+ context 'between? later(greater) time and same time' do
87
+ it { base_time.between?(later_time, base_time).should be_false }
88
+ end
89
+ context 'between? earlier(less) time and same time' do
90
+ it { base_time.between?(earlier_time, base_time).should be_true }
91
+ end
92
+ context 'between? same time and same time' do
93
+ it { base_time.between?(base_time, base_time).should be_true }
94
+ end
95
+ end
@@ -589,16 +589,6 @@ describe Vanadiel::Time, '#strftime' do
589
589
  end
590
590
  end
591
591
 
592
- describe Vanadiel::Time, '#==' do
593
- context 'with same value different object' do
594
- let(:other) { described_class.new(2047, 10, 21) }
595
- subject { described_class.new(2047, 10, 21) }
596
- it 'should be true' do
597
- should == other
598
- end
599
- end
600
- end
601
-
602
592
  describe Vanadiel::Time, '#eql?' do
603
593
  context 'with same value different object' do
604
594
  let(:other) { described_class.new(2047, 10, 21) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanadiel-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-09 00:00:00.000000000 Z
12
+ date: 2013-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -111,6 +111,7 @@ files:
111
111
  - lib/vanadiel/moon.rb
112
112
  - lib/vanadiel/time.rb
113
113
  - spec/spec_helper.rb
114
+ - spec/time_comparable_spec.rb
114
115
  - spec/time_spec.rb
115
116
  - vanadiel-time.gemspec
116
117
  homepage: https://github.com/pasela/vanadiel-time-gem
@@ -128,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
129
  version: '0'
129
130
  segments:
130
131
  - 0
131
- hash: -2818456796949850487
132
+ hash: -943493964579600112
132
133
  required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  none: false
134
135
  requirements:
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  version: '0'
138
139
  segments:
139
140
  - 0
140
- hash: -2818456796949850487
141
+ hash: -943493964579600112
141
142
  requirements: []
142
143
  rubyforge_project:
143
144
  rubygems_version: 1.8.23
@@ -146,4 +147,6 @@ specification_version: 3
146
147
  summary: A library for dealing with Vana'diel time from Final Fantasy XI
147
148
  test_files:
148
149
  - spec/spec_helper.rb
150
+ - spec/time_comparable_spec.rb
149
151
  - spec/time_spec.rb
152
+ has_rdoc: