Class: Dasht::Board

Inherits:
Object
  • Object
show all
Defined in:
lib/dasht/board.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name) ⇒ Board

Returns a new instance of Board.



12
13
14
15
16
# File 'lib/dasht/board.rb', line 12

def initialize(parent, name)
  @parent = parent
  @name  = name
  @tiles = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/dasht/board.rb', line 37

def method_missing(method, *args, &block)
  begin
    metric = args.shift
    options = args.pop || {}
    @tiles << {
      :type       => method,
      :metric     => metric,
      :resolution => self.default_resolution || parent.default_resolution || 60,
      :refresh    => self.default_refresh    || parent.default_refresh    || 5,
      :width      => self.default_width      || parent.default_width      || 3,
      :height     => self.default_height     || parent.default_height     || 3,
      :extra_args => args
    }.merge(options)
  rescue => e
    super(method, *args, &block)
  end
end

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.



6
7
8
# File 'lib/dasht/board.rb', line 6

def background
  @background
end

#default_heightObject

Returns the value of attribute default_height.



10
11
12
# File 'lib/dasht/board.rb', line 10

def default_height
  @default_height
end

#default_refreshObject

Returns the value of attribute default_refresh.



8
9
10
# File 'lib/dasht/board.rb', line 8

def default_refresh
  @default_refresh
end

#default_resolutionObject

Returns the value of attribute default_resolution.



7
8
9
# File 'lib/dasht/board.rb', line 7

def default_resolution
  @default_resolution
end

#default_widthObject

Returns the value of attribute default_width.



9
10
11
# File 'lib/dasht/board.rb', line 9

def default_width
  @default_width
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/dasht/board.rb', line 4

def name
  @name
end

#parentObject

Returns the value of attribute parent.



3
4
5
# File 'lib/dasht/board.rb', line 3

def parent
  @parent
end

#tilesObject

Returns the value of attribute tiles.



5
6
7
# File 'lib/dasht/board.rb', line 5

def tiles
  @tiles
end

Instance Method Details

#emit_plugin_cssObject



25
26
27
# File 'lib/dasht/board.rb', line 25

def emit_plugin_css
  _emit_css(parent.system_plugins_path)
end

#emit_plugin_htmlObject



29
30
31
# File 'lib/dasht/board.rb', line 29

def emit_plugin_html
  _emit_html(parent.system_plugins_path)
end

#emit_plugin_jsObject



33
34
35
# File 'lib/dasht/board.rb', line 33

def emit_plugin_js
  _emit_js(parent.system_plugins_path)
end

#to_htmlObject



18
19
20
21
22
23
# File 'lib/dasht/board.rb', line 18

def to_html
  # Load the erb.
  path = File.join(parent.views_path, "dashboard.erb")
  @erb = ERB.new(IO.read(path))
  @erb.result(binding)
end