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, #index, #inspect, #next_siblings, #prev_siblings, #siblings, #text, #text_, #to_s

Methods included from Navigation::Sections::Node

#in_sections

Methods included from Navigation::Shortcuts::Node

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

Methods included from Navigation::Lookup::Node

#_lookup, #_lookup_children, #_lookup_next_siblings, #_lookup_parents, #_lookup_prev_siblings, #_lookup_siblings, #_matches?, #has_parent?, #lookup, #lookup_children, #lookup_next_siblings, #lookup_parents, #lookup_prev_siblings, #lookup_siblings, #matches?

Constructor Details

#initialize(path, params = {}) ⇒ Image

Returns a new instance of Image.



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

def initialize(path, params = {})
  @caption = params.delete(:caption)
  super({path: path}.merge(params))
end

Instance Attribute Details

#alignmentObject (readonly)



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

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

#altObject (readonly)



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

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

#captionNodes (readonly)

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

Returns:



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

def caption
  @caption
end


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

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

#locationObject (readonly)



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

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

#pathObject (readonly)



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

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

#typeObject (readonly)



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

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

Instance Method Details

#border?Boolean

Returns:

  • (Boolean)


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

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

#heightObject



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

def height
  params[:height].to_i
end

#to_tree(level = 0) ⇒ Object



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

def to_tree(level = 0)
  super(level) +
    if caption && !caption.empty?
      indent(level+1) + "caption:\n" +
        caption.map(&call(to_tree: level+2)).join
    else
      ''
    end
end

#widthObject



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

def width
  params[:width].to_i
end