Class: Moodwall::Optparse::ScriptOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/moodwall/optparse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScriptOptions

Returns a new instance of ScriptOptions.



23
24
25
26
27
28
29
# File 'lib/moodwall/optparse.rb', line 23

def initialize
  self.change    = true
  self.add       = false
  self.list      = false
  self.mood      = false
  self.wallpaper = true
end

Instance Attribute Details

#addObject

Returns the value of attribute add.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def add
  @add
end

#changeObject

Returns the value of attribute change.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def change
  @change
end

#listObject

Returns the value of attribute list.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def list
  @list
end

#moodObject

Returns the value of attribute mood.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def mood
  @mood
end

#mood_nameObject

Returns the value of attribute mood_name.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def mood_name
  @mood_name
end

#pathObject

Returns the value of attribute path.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def path
  @path
end

#wallpaperObject

Returns the value of attribute wallpaper.



20
21
22
# File 'lib/moodwall/optparse.rb', line 20

def wallpaper
  @wallpaper
end

Instance Method Details

#add_option(parser) ⇒ Object



64
65
66
67
68
69
# File 'lib/moodwall/optparse.rb', line 64

def add_option(parser)
  parser.on("-a", "--add", "Add [target]") do
    self.add = true
    self.change = false
  end
end

#change_option(parser) ⇒ Object



57
58
59
60
61
62
# File 'lib/moodwall/optparse.rb', line 57

def change_option(parser)
  parser.on("-c", "--change", "Change [target]") do
    self.change = true
    self.add = false
  end
end

#define_options(parser) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/moodwall/optparse.rb', line 31

def define_options(parser)
  parser.banner = "Usage: moodwall [options]\nDefaults: moodwall -c -w"
  parser.separator ""
  parser.separator "Specific options"

  change_option(parser)
  add_option(parser)
  list_option(parser)

  wallpaper_option(parser)
  mood_option(parser)

  parser.separator ""
  parser.separator "Common options:"

  parser.on_tail("-h", "--help", "Show this message") do
    puts parser
    exit
  end

  parser.on_tail("-v", "--version", "Show version") do
    puts Moodwall::VERSION
    exit
  end
end

#list_option(parser) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/moodwall/optparse.rb', line 71

def list_option(parser)
  parser.on("-l", "--list", "List [targets]") do
    self.list = true
    self.add = false
    self.change = false
  end
end

#mood_option(parser) ⇒ Object



86
87
88
89
90
91
# File 'lib/moodwall/optparse.rb', line 86

def mood_option(parser)
  parser.on("-m", "--mood [NAME]", "Specifies mood name") do |mood_name|
    self.mood = true
    self.mood_name = mood_name
  end
end

#wallpaper_option(parser) ⇒ Object



79
80
81
82
83
84
# File 'lib/moodwall/optparse.rb', line 79

def wallpaper_option(parser)
  parser.on("-w", "--wallpaper [PATH]", "Specifies wallpaper path") do |path|
    self.wallpaper = true
    self.path = path
  end
end