Class: Plugins::MonthPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/bujo/plugins/month_plugin.rb

Instance Attribute Summary

Attributes inherited from Plugin

#name, #options

Instance Method Summary collapse

Methods inherited from Plugin

#==, #shortcuts

Constructor Details

#initialize(dependencies = []) ⇒ MonthPlugin

Returns a new instance of MonthPlugin.



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/month_plugin.rb', line 9

def initialize(dependencies = [])
  super("month", [
      Options::Option.builder
          .with_name("this-month")
          .with_description("Create an entry for this month in the journal")
          .with_action(-> { create_this_month })
          .build,
      Options::Option.builder
          .with_name("next-month")
          .with_description("Create an entry for next month in the journal")
          .with_action(-> { create_next_month })
          .build,
      Options::Option.builder
          .with_name("month")
          .with_description("Create an entry for the given month in the journal")
          .valued
          .with_action(lambda { |month| create_month(month) })
          .build
  ])

  @template_renderer = dependencies[:template_renderer]
end

Instance Method Details

#create_month(month_as_string) ⇒ Object



46
47
48
49
50
# File 'lib/bujo/plugins/month_plugin.rb', line 46

def create_month(month_as_string)
  date = Utils::DateUtils.parse_human_readable_month(month_as_string)
  puts "Creating an entry for #{month_as_string} in the journal"
  do_create_month(date)
end

#create_next_monthObject



41
42
43
44
# File 'lib/bujo/plugins/month_plugin.rb', line 41

def create_next_month
  puts "Creating an entry for next month (#{Utils::DateUtils.human_readable_month(Date.today.next_month)}) in the journal"
  do_create_month(Date.today.next_month)
end

#create_this_monthObject



36
37
38
39
# File 'lib/bujo/plugins/month_plugin.rb', line 36

def create_this_month
  puts "Creating an entry for this month (#{Utils::DateUtils.human_readable_month}) in the journal"
  do_create_month
end

#directoryObject



32
33
34
# File 'lib/bujo/plugins/month_plugin.rb', line 32

def directory
  "logs"
end