Class: Uttk::Dumpers::Html::BaseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/uttk/dumpers/Html.rb

Overview

:nodoc:

Direct Known Subclasses

Leaf, Node

Constant Summary collapse

@@template_images =
Html.base_url + 'images/%%%IMAGE_SPLIT%%%triangle.gif'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ BaseNode

Returns a new instance of BaseNode.



60
61
62
63
# File 'lib/uttk/dumpers/Html.rb', line 60

def initialize ( h )
  @father, @status, @id = h[:father], h[:status], h[:id]
  @name, @contents, @state = h[:name], h[:contents], h[:state]
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



56
57
58
# File 'lib/uttk/dumpers/Html.rb', line 56

def contents
  @contents
end

#fatherObject (readonly)

Returns the value of attribute father.



56
57
58
# File 'lib/uttk/dumpers/Html.rb', line 56

def father
  @father
end

#idObject (readonly)

Returns the value of attribute id.



56
57
58
# File 'lib/uttk/dumpers/Html.rb', line 56

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



56
57
58
# File 'lib/uttk/dumpers/Html.rb', line 56

def name
  @name
end

#stateObject (readonly)

Returns the value of attribute state.



56
57
58
# File 'lib/uttk/dumpers/Html.rb', line 56

def state
  @state
end

#statusObject (readonly)

Returns the value of attribute status.



56
57
58
# File 'lib/uttk/dumpers/Html.rb', line 56

def status
  @status
end

Instance Method Details

#htmlObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/uttk/dumpers/Html.rb', line 69

def html
  @status ||= ''
  x = XmlMarkup.new
  x.div :class => self.class.name.demodulize.underscore do
    x.table :class => 'title', :id => unquote(status).sub(/\(.+\)/, '') do
      x.tr do
        if state == 2
          x.td { x.text!(name.to_s + ': ') }
          x.td { x.pre clean_yaml_str(contents),
                       :class => 'attribute_alone' }
        else
          x.td :width => '11px',
               :onClick => "uttk_toggle_state(#{id.gsub('"', "'")})" do
            x.img :src => @@template_images
          end
          x.td { x.text!(name.to_s) }
          x.td(:width => '20px') { x.text!(unquote(status).gsub('NONE', '')) }
        end
      end
    end
  end
  result = x.target!
  raise unless result =~ /<\/div>\Z/
  result.sub!(/<\/div>\Z/, '')
  result.split('%%%IMAGE_SPLIT%%%').map do |x|
    x.dump
  end.join(', ')
end

#unquote(s) ⇒ Object



65
66
67
# File 'lib/uttk/dumpers/Html.rb', line 65

def unquote ( s )
  s.gsub('"', '')
end