Class: Moodwall::Optparse::ScriptOptions
- Inherits:
-
Object
- Object
- Moodwall::Optparse::ScriptOptions
- Defined in:
- lib/moodwall/optparse.rb
Instance Attribute Summary collapse
-
#add ⇒ Object
Returns the value of attribute add.
-
#change ⇒ Object
Returns the value of attribute change.
-
#list ⇒ Object
Returns the value of attribute list.
-
#mood ⇒ Object
Returns the value of attribute mood.
-
#mood_name ⇒ Object
Returns the value of attribute mood_name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#wallpaper ⇒ Object
Returns the value of attribute wallpaper.
Instance Method Summary collapse
- #add_option(parser) ⇒ Object
- #change_option(parser) ⇒ Object
- #define_options(parser) ⇒ Object
-
#initialize ⇒ ScriptOptions
constructor
A new instance of ScriptOptions.
- #list_option(parser) ⇒ Object
- #mood_option(parser) ⇒ Object
- #wallpaper_option(parser) ⇒ Object
Constructor Details
#initialize ⇒ ScriptOptions
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
#add ⇒ Object
Returns the value of attribute add.
20 21 22 |
# File 'lib/moodwall/optparse.rb', line 20 def add @add end |
#change ⇒ Object
Returns the value of attribute change.
20 21 22 |
# File 'lib/moodwall/optparse.rb', line 20 def change @change end |
#list ⇒ Object
Returns the value of attribute list.
20 21 22 |
# File 'lib/moodwall/optparse.rb', line 20 def list @list end |
#mood ⇒ Object
Returns the value of attribute mood.
20 21 22 |
# File 'lib/moodwall/optparse.rb', line 20 def mood @mood end |
#mood_name ⇒ Object
Returns the value of attribute mood_name.
20 21 22 |
# File 'lib/moodwall/optparse.rb', line 20 def mood_name @mood_name end |
#path ⇒ Object
Returns the value of attribute path.
20 21 22 |
# File 'lib/moodwall/optparse.rb', line 20 def path @path end |
#wallpaper ⇒ Object
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 (parser) parser. = "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 |