Class: Plugins::DayPlugin
- Defined in:
- lib/bujo/plugins/day_plugin.rb
Instance Attribute Summary
Attributes inherited from Plugin
Instance Method Summary collapse
- #create_day(date_as_string) ⇒ Object
- #create_today ⇒ Object
- #create_tomorrow ⇒ Object
- #directory ⇒ Object
-
#initialize(dependencies = []) ⇒ DayPlugin
constructor
A new instance of DayPlugin.
Methods inherited from Plugin
Constructor Details
#initialize(dependencies = []) ⇒ DayPlugin
Returns a new instance of DayPlugin.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bujo/plugins/day_plugin.rb', line 9 def initialize(dependencies = []) super("day", [ Options::Option.builder .with_name("today") .with_description("Create an entry for today in the journal") .with_action(-> { create_today }) .build, Options::Option.builder .with_name("tomorrow") .with_description("Create an entry for tomorrow in the journal") .with_action(-> { create_tomorrow }) .build, Options::Option.builder .with_name("date") .with_description("Create an entry for the given date in the journal") .valued .with_action(lambda { |value| create_day(value) }) .build ]) @template_renderer = dependencies[:template_renderer] end |
Instance Method Details
#create_day(date_as_string) ⇒ Object
46 47 48 49 50 |
# File 'lib/bujo/plugins/day_plugin.rb', line 46 def create_day(date_as_string) date = Utils::DateUtils.parse_human_readable_date(date_as_string) puts "Creating an entry for #{date_as_string} in the journal" do_create_day(date) end |
#create_today ⇒ Object
36 37 38 39 |
# File 'lib/bujo/plugins/day_plugin.rb', line 36 def create_today puts "Creating an entry for today (#{Utils::DateUtils.human_readable_date}) in the journal" do_create_day end |
#create_tomorrow ⇒ Object
41 42 43 44 |
# File 'lib/bujo/plugins/day_plugin.rb', line 41 def create_tomorrow puts "Creating an entry for tomorrow (#{Utils::DateUtils.human_readable_date(Date.today.next_day)}) in the journal" do_create_day(Date.today.next_day) end |
#directory ⇒ Object
32 33 34 |
# File 'lib/bujo/plugins/day_plugin.rb', line 32 def directory "logs" end |