Module: Relevant::Widget::ClassMethods

Defined in:
lib/relevant/widget.rb

Instance Method Summary collapse

Instance Method Details

#_default_labelObject



48
49
50
# File 'lib/relevant/widget.rb', line 48

def _default_label
  name.demodulize.gsub(/[[A-Z]]/, ' \0').strip
end

#available_options(options = nil) ⇒ Object



28
29
30
# File 'lib/relevant/widget.rb', line 28

def available_options(options = nil)
  options.nil? ? @available_options : (@available_options = options)
end

#label(the_label = _default_label) ⇒ Object



44
45
46
# File 'lib/relevant/widget.rb', line 44

def label(the_label = _default_label)
  @label ||= the_label
end

#refresh_every(seconds = nil) ⇒ Object



40
41
42
# File 'lib/relevant/widget.rb', line 40

def refresh_every(seconds = nil)
  seconds.nil? ? @refresh_every : (@refresh_every = seconds)
end

#setup(options = {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/relevant/widget.rb', line 21

def setup(options = {})
  widget = new
  widget.options = options.reject{|key,val| val.blank?}
  
  widget
end

#template(data = nil) ⇒ Object



36
37
38
# File 'lib/relevant/widget.rb', line 36

def template(data = nil)
  data.nil? ? @template : (@template = data)
end

#template_format(format = nil) ⇒ Object



32
33
34
# File 'lib/relevant/widget.rb', line 32

def template_format(format = nil)
  format.nil? ? @template_format : (@template_format = format)
end