Class: NightTime::Jst
- Inherits:
-
Object
- Object
- NightTime::Jst
- Defined in:
- lib/night-time/jst.rb
Defined Under Namespace
Classes: Build
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text) ⇒ Jst
constructor
A new instance of Jst.
- #parse ⇒ Object
- #parse! ⇒ Object
- #parsedate ⇒ Object
- #time(now = nil) ⇒ Object
Constructor Details
Class Method Details
.parse(text, now = nil) ⇒ Object
6 7 8 |
# File 'lib/night-time/jst.rb', line 6 def self.parse(text, now = nil) new(text).time(now) end |
Instance Method Details
#parse ⇒ Object
30 31 32 |
# File 'lib/night-time/jst.rb', line 30 def parse parsedate end |
#parse! ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/night-time/jst.rb', line 51 def parse! build! if @build.full? return @build.to_time elsif @build.date? build = @build.dup build.year ||= Time.now.year return build.to_time else return nil end end |
#parsedate ⇒ Object
25 26 27 28 |
# File 'lib/night-time/jst.rb', line 25 def parsedate build! @build.to_array end |
#time(now = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/night-time/jst.rb', line 34 def time(now = nil) unless now now = Time.now now = Time.mktime(now.year, now.month, now.day) end build! b = @build.dup b.year ||= now.year b.month ||= now.month b.day ||= now.day b.hour ||= now.hour b.min ||= now.min b.sec ||= now.sec return b.to_time end |