Module: FN::Node::Base
- Extended by:
- Base
- Included in:
- Base, Root, PDF::Node::BeginDocument, PDF::Node::BeginPageExt, PDF::Node::CreateTextflow, PDF::Node::EndPageExt, PDF::Node::FitImage, PDF::Node::FitPdiPage, PDF::Node::FitTextflow, PDF::Node::Invert, PDF::Node::LoadImage, PDF::Node::OpenPdi, PDF::Node::OpenPdiPage, PDF::Node::ResumePage, PDF::Node::SetParameter, PDF::Node::Watermark, SWF::Node::Break, SWF::Node::Flash, SWF::Node::Font, SWF::Node::Frame, SWF::Node::HotSpot, SWF::Node::Image, SWF::Node::Page, SWF::Node::PhotoBlock, SWF::Node::Text
- Defined in:
- lib/fn/node/base.rb
Constant Summary collapse
- CURRENT_PAGE_WIDTH =
"__current_page_width"
- CURRENT_PAGE_HEIGHT =
"__current_page_height"
Instance Method Summary collapse
- #classify(name) ⇒ Object
- #has_no_children ⇒ Object
- #mixin(node) ⇒ Object
- #value(v) ⇒ Object
- #visit(struct, debug = false) ⇒ Object
- #visit_children(struct, debug = false) ⇒ Object
- #with_attributes_like(node) ⇒ Object
Instance Method Details
#classify(name) ⇒ Object
51 52 53 |
# File 'lib/fn/node/base.rb', line 51 def classify(name) name.split("_").map{|s| s.capitalize}.join("") end |
#has_no_children ⇒ Object
20 21 22 |
# File 'lib/fn/node/base.rb', line 20 def has_no_children raise "should have no children" if children.any?{|c| !c.cdata?} end |
#mixin(node) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/fn/node/base.rb', line 44 def mixin(node) name = classify(node.name) mod = FN::SWF::Node.const_get(name) rescue FN::PDF::Node.const_get(name) node.extend(mod) end |
#value(v) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/fn/node/base.rb', line 62 def value(v) case v when Array v.map{|e| value(e)}.join(" ") else v.to_s end end |
#visit(struct, debug = false) ⇒ Object
16 17 18 |
# File 'lib/fn/node/base.rb', line 16 def visit(struct, debug = false) visit_children(struct, debug) end |
#visit_children(struct, debug = false) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fn/node/base.rb', line 24 def visit_children(struct, debug = false) if debug puts "="*88 puts "Visiting Children" puts "Struct" puts struct.inspect puts "-"*88 puts "Children" puts children.inspect puts "="*88 end children.each do |c| if c.element? mixin(c) c.visit(struct, debug) end end return struct end |
#with_attributes_like(node) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/fn/node/base.rb', line 55 def with_attributes_like(node) node.attributes.each do |attr| self[attr.name] = attr.value end self end |