Class: Standupguy::Core
- Inherits:
-
Object
- Object
- Standupguy::Core
- Defined in:
- lib/Standupguy.rb
Overview
Generic methods that were moved from bin/standupguy to here in order to better test this code. Mostly init stuff.
Constant Summary collapse
- DATA_ROOT =
File.join(ENV["HOME"], ".standupguy")
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #first_time! ⇒ Object
-
#initialize(options) ⇒ Core
constructor
A new instance of Core.
- #report ⇒ Object
- #show ⇒ Object
Constructor Details
#initialize(options) ⇒ Core
Returns a new instance of Core.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/Standupguy.rb', line 52 def initialize() @options = first_time! unless Dir.exist?(DATA_ROOT) @options[:date] ||= DateTime.now.strftime("%Y-%m-%d") if @options[:item] item = Standupguy::Item.new item.add_to_today(@options[:item]) item.save end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
50 51 52 |
# File 'lib/Standupguy.rb', line 50 def @options end |
Instance Method Details
#first_time! ⇒ Object
81 82 83 84 85 |
# File 'lib/Standupguy.rb', line 81 def first_time! Kernel.puts("First time running...\nCreating data directory") Dir.mkdir(DATA_ROOT) File.open(File.join(DATA_ROOT, "standup.json"), "a+").close end |
#report ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/Standupguy.rb', line 70 def report case @options[:report] when "HTML" Standupguy::HTMLReport.new(@options[:date]) when "EMAIL" Standupguy::EmailReport.new(@options[:date]) else Standupguy::TextReport.new(@options[:date]) end end |
#show ⇒ Object
66 67 68 |
# File 'lib/Standupguy.rb', line 66 def show report.show end |