Class: Datte::Dattetime
- Inherits:
-
Object
- Object
- Datte::Dattetime
- Defined in:
- lib/datte/dattetime.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ force_update: false }
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#hour ⇒ Object
readonly
Returns the value of attribute hour.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#sec ⇒ Object
readonly
Returns the value of attribute sec.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#after_date(year, month, day) ⇒ Object
何年後、何ヶ月後、何日後.
-
#after_time(hour, min) ⇒ Object
何時間後、何分後.
-
#initialize(options = {}) ⇒ Dattetime
constructor
A new instance of Dattetime.
- #to_datetime ⇒ Object
- #to_s ⇒ Object
-
#update_date(md, options = @options) ⇒ Object
年か月か日を更新.
-
#update_time(hour, min) ⇒ Object
時か分を更新.
Constructor Details
#initialize(options = {}) ⇒ Dattetime
Returns a new instance of Dattetime.
10 11 12 13 |
# File 'lib/datte/dattetime.rb', line 10 def initialize( = {}) = DEFAULT_OPTIONS.merge() @date = Date.today end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
8 9 10 |
# File 'lib/datte/dattetime.rb', line 8 def day @day end |
#hour ⇒ Object (readonly)
Returns the value of attribute hour.
8 9 10 |
# File 'lib/datte/dattetime.rb', line 8 def hour @hour end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
8 9 10 |
# File 'lib/datte/dattetime.rb', line 8 def min @min end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
8 9 10 |
# File 'lib/datte/dattetime.rb', line 8 def month @month end |
#sec ⇒ Object (readonly)
Returns the value of attribute sec.
8 9 10 |
# File 'lib/datte/dattetime.rb', line 8 def sec @sec end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
8 9 10 |
# File 'lib/datte/dattetime.rb', line 8 def year @year end |
Instance Method Details
#after_date(year, month, day) ⇒ Object
何年後、何ヶ月後、何日後
36 37 |
# File 'lib/datte/dattetime.rb', line 36 def after_date(year, month, day) end |
#after_time(hour, min) ⇒ Object
何時間後、何分後
40 41 |
# File 'lib/datte/dattetime.rb', line 40 def after_time(hour, min) end |
#to_datetime ⇒ Object
19 20 21 |
# File 'lib/datte/dattetime.rb', line 19 def to_datetime DateTime.new(@year, @month, @day, 12, 0, 0) rescue nil end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/datte/dattetime.rb', line 15 def to_s @date.to_s end |
#update_date(md, options = @options) ⇒ Object
年か月か日を更新
24 25 26 27 28 29 |
# File 'lib/datte/dattetime.rb', line 24 def update_date(md, = ) op = [:force_update] ? '=' : '||=' eval("@year #{op} year!(md)") eval("@month #{op} month!(md)") eval("@day #{op} day!(md)") end |
#update_time(hour, min) ⇒ Object
時か分を更新
32 33 |
# File 'lib/datte/dattetime.rb', line 32 def update_time(hour, min) end |