Class: Termplot::Options
- Inherits:
-
Object
- Object
- Termplot::Options
- Defined in:
- lib/termplot/options.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#cols ⇒ Object
readonly
Returns the value of attribute cols.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#line_style ⇒ Object
readonly
Returns the value of attribute line_style.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #mode ⇒ Object
- #parse_options! ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/termplot/options.rb', line 18 def initialize @rows = 19 @cols = 80 @title = "Series" @line_style = "line" @color = "red" @debug = false @command = nil @interval = 1000 end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def color @color end |
#cols ⇒ Object (readonly)
Returns the value of attribute cols.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def cols @cols end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def command @command end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def debug @debug end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def interval @interval end |
#line_style ⇒ Object (readonly)
Returns the value of attribute line_style.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def line_style @line_style end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def rows @rows end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/termplot/options.rb', line 9 def title @title end |
Instance Method Details
#mode ⇒ Object
29 30 31 |
# File 'lib/termplot/options.rb', line 29 def mode @command.nil? ? :stdin : :command end |
#parse_options! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/termplot/options.rb', line 33 def # Debug option is parsed manually to prevent it from showing up in the # options help parse_debug OptionParser.new do |opts| opts. = "Usage: termplot [OPTIONS]" parse_rows(opts) parse_cols(opts) parse_title(opts) parse_line_style(opts) parse_color(opts) parse_command(opts) parse_interval(opts) opts.on("-h", "--help", "Display this help message") do puts opts exit(0) end end.parse! self end |