Class: Infoboxer::Tree::Image
- Inherits:
-
Node
- Object
- Node
- Infoboxer::Tree::Image
show all
- Defined in:
- lib/infoboxer/tree/image.rb
Overview
Represents image (or other media file).
See Wikipedia Tutorial
for explanation of attributes.
Instance Attribute Summary collapse
Attributes inherited from Node
#params, #parent
Instance Method Summary
collapse
Methods inherited from Node
#==, #children, coder, def_readers, #first?, #index, #inspect, #next_siblings, #prev_siblings, #siblings, #text, #text_, #to_s
#wikipath
#in_sections
#bold?, #categories, #external_links, #heading?, #headings, #images, #infobox, #infoboxes, #italic?, #lists, #paragraphs, #tables, #templates, #wikilinks
#_lookup, #_lookup_children, #_lookup_next_siblings, #_lookup_parents, #_lookup_prev_sibling, #_lookup_prev_siblings, #_lookup_siblings, #_matches?, #lookup, #lookup_children, #lookup_next_siblings, #lookup_parents, #lookup_prev_sibling, #lookup_prev_siblings, #lookup_siblings, #matches?, #parent?
Constructor Details
#initialize(path, caption: nil, **params) ⇒ Image
Returns a new instance of Image.
8
9
10
11
|
# File 'lib/infoboxer/tree/image.rb', line 8
def initialize(path, caption: nil, **params)
@caption = caption
super({path: path}.merge(params))
end
|
Instance Attribute Details
#alignment ⇒ Object
25
26
27
|
# File 'lib/infoboxer/tree/image.rb', line 25
def_readers :path, :type,
:location, :alignment, :link,
:alt
|
#alt ⇒ Object
25
26
27
|
# File 'lib/infoboxer/tree/image.rb', line 25
def_readers :path, :type,
:location, :alignment, :link,
:alt
|
#caption ⇒ Nodes
Image caption. Can have (sometimes many) other nodes inside.
16
17
18
|
# File 'lib/infoboxer/tree/image.rb', line 16
def caption
@caption
end
|
#link ⇒ Object
25
26
27
|
# File 'lib/infoboxer/tree/image.rb', line 25
def_readers :path, :type,
:location, :alignment, :link,
:alt
|
#location ⇒ Object
25
26
27
|
# File 'lib/infoboxer/tree/image.rb', line 25
def_readers :path, :type,
:location, :alignment, :link,
:alt
|
#path ⇒ Object
25
26
27
|
# File 'lib/infoboxer/tree/image.rb', line 25
def_readers :path, :type,
:location, :alignment, :link,
:alt
|
#type ⇒ Object
25
26
27
|
# File 'lib/infoboxer/tree/image.rb', line 25
def_readers :path, :type,
:location, :alignment, :link,
:alt
|
Instance Method Details
#border? ⇒ Boolean
29
30
31
|
# File 'lib/infoboxer/tree/image.rb', line 29
def border?
!params[:border].to_s.empty?
end
|
#height ⇒ Object
37
38
39
|
# File 'lib/infoboxer/tree/image.rb', line 37
def height
params[:height].to_i
end
|
#to_tree(level = 0) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/infoboxer/tree/image.rb', line 41
def to_tree(level = 0)
super(level) +
if caption && !caption.empty?
indent(level + 1) + "caption:\n" +
caption.children.map { |c| c.to_tree(level + 2) }.join
else
''
end
end
|
#width ⇒ Object
33
34
35
|
# File 'lib/infoboxer/tree/image.rb', line 33
def width
params[:width].to_i
end
|