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.



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

#alignmentObject (readonly)



25
26
27
# File 'lib/infoboxer/tree/image.rb', line 25

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

#altObject (readonly)



25
26
27
# File 'lib/infoboxer/tree/image.rb', line 25

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

#captionNodes (readonly)

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

Returns:



16
17
18
# File 'lib/infoboxer/tree/image.rb', line 16

def caption
  @caption
end


25
26
27
# File 'lib/infoboxer/tree/image.rb', line 25

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

#locationObject (readonly)



25
26
27
# File 'lib/infoboxer/tree/image.rb', line 25

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

#pathObject (readonly)



25
26
27
# File 'lib/infoboxer/tree/image.rb', line 25

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

#typeObject (readonly)



25
26
27
# File 'lib/infoboxer/tree/image.rb', line 25

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

Instance Method Details

#border?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/infoboxer/tree/image.rb', line 29

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

#heightObject



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

#widthObject



33
34
35
# File 'lib/infoboxer/tree/image.rb', line 33

def width
  params[:width].to_i
end