Class: Infoboxer::Tree::Image

Inherits:
Node
  • Object
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

Methods included from Navigation::Wikipath

#wikipath

Methods included from Navigation::Sections::Node

#in_sections

Methods included from Navigation::Shortcuts::Node

#bold?, #categories, #external_links, #heading?, #headings, #images, #infobox, #infoboxes, #italic?, #lists, #paragraphs, #tables, #templates, #wikilinks

Methods included from Navigation::Lookup::Node

#_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.



10
11
12
13
# File 'lib/infoboxer/tree/image.rb', line 10

def initialize(path, caption: nil, **params)
  @caption = caption
  super(path: path, **params)
end

Instance Attribute Details

#alignmentObject (readonly)



27
28
29
# File 'lib/infoboxer/tree/image.rb', line 27

def_readers :path, :type,
:location, :alignment, :link,
:alt

#altObject (readonly)



27
28
29
# File 'lib/infoboxer/tree/image.rb', line 27

def_readers :path, :type,
:location, :alignment, :link,
:alt

#captionNodes (readonly)

Image caption. Can have (sometimes many) other nodes inside.

Returns:



18
19
20
# File 'lib/infoboxer/tree/image.rb', line 18

def caption
  @caption
end


27
28
29
# File 'lib/infoboxer/tree/image.rb', line 27

def_readers :path, :type,
:location, :alignment, :link,
:alt

#locationObject (readonly)



27
28
29
# File 'lib/infoboxer/tree/image.rb', line 27

def_readers :path, :type,
:location, :alignment, :link,
:alt

#pathObject (readonly)



27
28
29
# File 'lib/infoboxer/tree/image.rb', line 27

def_readers :path, :type,
:location, :alignment, :link,
:alt

#typeObject (readonly)



27
28
29
# File 'lib/infoboxer/tree/image.rb', line 27

def_readers :path, :type,
:location, :alignment, :link,
:alt

Instance Method Details

#border?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/infoboxer/tree/image.rb', line 31

def border?
  !params[:border].to_s.empty?
end

#heightObject



39
40
41
# File 'lib/infoboxer/tree/image.rb', line 39

def height
  params[:height].to_i
end

#to_tree(level = 0) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/infoboxer/tree/image.rb', line 43

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

#widthObject



35
36
37
# File 'lib/infoboxer/tree/image.rb', line 35

def width
  params[:width].to_i
end