Class: Qippet::Boxes::Box
- Inherits:
-
Object
- Object
- Qippet::Boxes::Box
show all
- Defined in:
- lib/qippet/boxes/box.rb
Overview
Abstract Class definiton for Box
Constant Summary
collapse
- PADDING =
40
- PADDING_X =
30
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Box
Returns a new instance of Box.
14
15
16
|
# File 'lib/qippet/boxes/box.rb', line 14
def initialize
self.class.setup_attributes
end
|
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
9
10
11
|
# File 'lib/qippet/boxes/box.rb', line 9
def image
@image
end
|
#node ⇒ Object
Returns the value of attribute node.
9
10
11
|
# File 'lib/qippet/boxes/box.rb', line 9
def node
@node
end
|
Class Method Details
.setup_attributes ⇒ Object
35
36
37
38
39
|
# File 'lib/qippet/boxes/box.rb', line 35
def self.setup_attributes
return unless const_defined? "ALLOWED_ATTRIBUTES"
self::ALLOWED_ATTRIBUTES.each { |attr| attr_accessor attr }
end
|
Instance Method Details
#add_attributes(attributes_value) ⇒ Object
30
31
32
33
|
# File 'lib/qippet/boxes/box.rb', line 30
def add_attributes(attributes_value)
allowed_attributes = attributes_value.filter { |key, _| self.class::ALLOWED_ATTRIBUTES.include?(key.to_sym) }
allowed_attributes.each { |key, val| instance_variable_set "@#{key}", val }
end
|
#add_child(child) ⇒ Object
18
19
20
|
# File 'lib/qippet/boxes/box.rb', line 18
def add_child(child)
children << child
end
|
#children ⇒ Object
26
27
28
|
# File 'lib/qippet/boxes/box.rb', line 26
def children
@children ||= []
end
|
#render ⇒ Object
22
23
24
|
# File 'lib/qippet/boxes/box.rb', line 22
def render
construct_box_image
end
|