Class: EmojiClock

Inherits:
Object
  • Object
show all
Extended by:
ClockVariety
Defined in:
lib/emoji_clock.rb,
lib/emoji_clock/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Constants included from ClockVariety

ClockVariety::ALARM_CLOCK, ClockVariety::EMOJI_CLOCK_CODE_POINT, ClockVariety::HOUR_GLASS_DONE, ClockVariety::HOUR_GLASS_UNDONE, ClockVariety::MANTELPIECE_CLOCK, ClockVariety::STOP_WATCH_CLOCK, ClockVariety::TIMER_CLOCK, ClockVariety::WATCH_CLOCK

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClockVariety

alarm, hourglass_done, hourglass_undone, mantelpiece, stop_watch, timer, watch

Constructor Details

#initialize(hour, minute) ⇒ EmojiClock

Returns a new instance of EmojiClock.



12
13
14
15
# File 'lib/emoji_clock.rb', line 12

def initialize(hour, minute)
  @hour = hour
  @minute = minute
end

Instance Attribute Details

#hourObject (readonly)

Returns the value of attribute hour.



9
10
11
# File 'lib/emoji_clock.rb', line 9

def hour
  @hour
end

#minuteObject (readonly)

Returns the value of attribute minute.



9
10
11
# File 'lib/emoji_clock.rb', line 9

def minute
  @minute
end

Class Method Details

.at(*args, exact: false) ⇒ Object



29
30
31
32
33
34
# File 'lib/emoji_clock.rb', line 29

def self.at(*args, exact: false)
  time = TimeParser.parse(*args)
  clock = new(time.hour, time.min)

  exact ? clock.fetch_exact_emoji : clock.fetch_emoji
end

.now(exact: false) ⇒ Object



25
26
27
# File 'lib/emoji_clock.rb', line 25

def self.now(exact: false)
  at(Time.now, exact: exact)
end

Instance Method Details

#fetch_emojiObject



17
18
19
# File 'lib/emoji_clock.rb', line 17

def fetch_emoji
  fetcher.fetch
end

#fetch_exact_emojiObject



21
22
23
# File 'lib/emoji_clock.rb', line 21

def fetch_exact_emoji
  fetcher.exact_fetch
end

#fetcherObject



36
37
38
# File 'lib/emoji_clock.rb', line 36

def fetcher
  @fetcher ||= EmojiClockFetcher.new(hour, minute)
end