Class: GitScribe::Options
- Inherits:
-
Hash
- Object
- Hash
- GitScribe::Options
- Defined in:
- lib/gitscribe/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #default_output ⇒ Object
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitscribe/options.rb', line 5 def initialize(args) super() self[:title] = "Cool Tutorial" self[:location] = "Vancouver, BC" @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} cool-tutorial" o.on('--output [FILE]', 'Output file to generate blog post to') do |output| self[:output] = output end o.on('--title [TITLE]', 'Blog post title to use', "Default: #{self[:title]}") do |title| self[:title] = title self[:output] = default_output unless self[:output] end o.on('--location [LOCATION]', 'Add geo location to the blog post', "Default: #{self[:location]}") do |location| self[:location] = location end o.on_tail('-h', '--help', 'display this help and exit') do self[:show_help] = true end end @opts.parse!(args) end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
3 4 5 |
# File 'lib/gitscribe/options.rb', line 3 def opts @opts end |
Instance Method Details
#default_output ⇒ Object
35 36 37 |
# File 'lib/gitscribe/options.rb', line 35 def default_output "#{Date.today.strftime("%Y-%m-%d")}-#{self[:title].gsub(/\s/, '-').downcase}.textile" end |