Class: MyChart::Dsl::Draw::ChartCmdARGV

Inherits:
Object
  • Object
show all
Defined in:
lib/my_chart/dsl/draw.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#optObject (readonly)

Returns the value of attribute opt.



47
48
49
# File 'lib/my_chart/dsl/draw.rb', line 47

def opt
  @opt
end

#xObject (readonly)

Returns the value of attribute x.



47
48
49
# File 'lib/my_chart/dsl/draw.rb', line 47

def x
  @x
end

#yObject (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_idObject



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

#limitObject



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

#sortObject



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