Class: Demos::Spreadsheet::Cell

Inherits:
Hokusai::Block show all
Defined in:
ui/examples/spreadsheet/csv.rb

Instance Attribute Summary

Attributes inherited from Hokusai::Block

#node, #provides, #publisher

Instance Method Summary collapse

Methods inherited from Hokusai::Block

#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, #initialize, inject, inject!, #method_missing, mount, #on_resize, provide, provides, #render, style, styles_get, template, template_from_file, template_get, #update, use, uses

Constructor Details

This class inherits a constructor from Hokusai::Block

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hokusai::Block

Instance Method Details

#cell_backgroundObject



43
44
45
# File 'ui/examples/spreadsheet/csv.rb', line 43

def cell_background
  node.meta.focused ? Hokusai::Color.new(27, 31, 50,255) : nil
end

#cell_contentObject



39
40
41
# File 'ui/examples/spreadsheet/csv.rb', line 39

def cell_content
  cell.nil? ? "" : cell
end

#emit_changed_cell(value) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'ui/examples/spreadsheet/csv.rb', line 51

def emit_changed_cell(value)
  if value =~ /^=/
    value = value.gsub('=', '')
    positions = value.split("-")

    emit("cell_forumla", index, *positions)
  else
    emit("cell_updated", index, value)
  end
end

#emit_modifiedObject



47
48
49
# File 'ui/examples/spreadsheet/csv.rb', line 47

def emit_modified
  emit("cell_modified", index)
end

#heightObject



69
70
71
# File 'ui/examples/spreadsheet/csv.rb', line 69

def height
  @height || 0.0
end

#update_height(height) ⇒ Object



62
63
64
65
66
67
# File 'ui/examples/spreadsheet/csv.rb', line 62

def update_height(height)
  @height = height
  node.meta.set_prop(:height, height)

  emit("height_updated", height, index)
end