Class: MyChart::Dsl::Draw::ChartCmdARGV
- Inherits:
-
Object
- Object
- MyChart::Dsl::Draw::ChartCmdARGV
- Defined in:
- lib/my_chart/dsl/draw.rb
Instance Attribute Summary collapse
-
#opt ⇒ Object
readonly
Returns the value of attribute opt.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #data_id ⇒ Object
-
#initialize(*arg) ⇒ ChartCmdARGV
constructor
A new instance of ChartCmdARGV.
- #limit ⇒ Object
- #method_missing(name, *arg) ⇒ Object
- #sort ⇒ Object
Constructor Details
#initialize(*arg) ⇒ ChartCmdARGV
49 50 51 52 53 54 |
# File 'lib/my_chart/dsl/draw.rb', line 49 def initialize *arg return if arg.empty? @opt = (arg[-1].kind_of? Hash) ? arg[-1] : {} @x = arg[0] if arg[0].kind_of? Symbol @y = arg[1] if arg[1] and arg[1].kind_of? Symbol end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arg) ⇒ Object
56 57 58 59 |
# File 'lib/my_chart/dsl/draw.rb', line 56 def method_missing name, *arg return opt[name] if [:w, :h, :name, :from, :keys, :asc, :desc, :first, :last].include? name super end |
Instance Attribute Details
#opt ⇒ Object (readonly)
Returns the value of attribute opt.
47 48 49 |
# File 'lib/my_chart/dsl/draw.rb', line 47 def opt @opt end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
47 48 49 |
# File 'lib/my_chart/dsl/draw.rb', line 47 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
47 48 49 |
# File 'lib/my_chart/dsl/draw.rb', line 47 def y @y end |
Instance Method Details
#data_id ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/my_chart/dsl/draw.rb', line 71 def data_id [x, y ? y : "no_y", keys ? "keys_#{keys.hash}" : "no_keys", from ? "from_#{from}" : "from_all", sort, limit ].compact.join '__' end |
#limit ⇒ Object
66 67 68 69 |
# File 'lib/my_chart/dsl/draw.rb', line 66 def limit lm = (first and :first) or (last and :last) [lm, (first or last)].join('_') if lm end |
#sort ⇒ Object
61 62 63 64 |
# File 'lib/my_chart/dsl/draw.rb', line 61 def sort order = (asc and :asc) or (desc and :desc) [order, 'by', (asc or desc)].join('_') if order end |