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.
   
 
  
  
    | 
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
    
      
      
      
  
  
    #alignment  ⇒ Object  
  
  
  
  
    | 
27
28
29 | # File 'lib/infoboxer/tree/image.rb', line 27
def_readers :path, :type,
:location, :alignment, :link,
:alt
 | 
 
    
      
      
      
  
  
    #alt  ⇒ Object  
  
  
  
  
    | 
27
28
29 | # File 'lib/infoboxer/tree/image.rb', line 27
def_readers :path, :type,
:location, :alignment, :link,
:alt
 | 
 
    
      
      
      
  
  
    #caption  ⇒ Nodes  
  
  
  
  
    Image caption. Can have (sometimes many) other nodes inside.
   
 
  
    | 
18
19
20 | # File 'lib/infoboxer/tree/image.rb', line 18
def caption
  @caption
end
 | 
 
    
      
      
      
  
  
    #link  ⇒ Object  
  
  
  
  
    | 
27
28
29 | # File 'lib/infoboxer/tree/image.rb', line 27
def_readers :path, :type,
:location, :alignment, :link,
:alt
 | 
 
    
      
      
      
  
  
    #location  ⇒ Object  
  
  
  
  
    | 
27
28
29 | # File 'lib/infoboxer/tree/image.rb', line 27
def_readers :path, :type,
:location, :alignment, :link,
:alt
 | 
 
    
      
      
      
  
  
    #path  ⇒ Object  
  
  
  
  
    | 
27
28
29 | # File 'lib/infoboxer/tree/image.rb', line 27
def_readers :path, :type,
:location, :alignment, :link,
:alt
 | 
 
    
      
      
      
  
  
    #type  ⇒ Object  
  
  
  
  
    | 
27
28
29 | # File 'lib/infoboxer/tree/image.rb', line 27
def_readers :path, :type,
:location, :alignment, :link,
:alt
 | 
 
    
   
  
    Instance Method Details
    
      
  
  
    #border?  ⇒ Boolean 
  
  
  
  
    | 
31
32
33 | # File 'lib/infoboxer/tree/image.rb', line 31
def border?
  !params[:border].to_s.empty?
end
 | 
 
    
      
  
  
    #height  ⇒ Object 
  
  
  
  
    | 
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
 | 
 
    
      
  
  
    #width  ⇒ Object 
  
  
  
  
    | 
35
36
37 | # File 'lib/infoboxer/tree/image.rb', line 35
def width
  params[:width].to_i
end
 |