Module: FN::SWF::Node

Included in:
Writer
Defined in:
lib/fn/swf/node/font.rb,
lib/fn/swf/node/page.rb,
lib/fn/swf/node/text.rb,
lib/fn/swf/node/break.rb,
lib/fn/swf/node/flash.rb,
lib/fn/swf/node/frame.rb,
lib/fn/swf/node/image.rb,
lib/fn/swf/node/hot_spot.rb,
lib/fn/swf/node/photo_block.rb

Defined Under Namespace

Modules: Break, Flash, Font, Frame, HotSpot, Image, Page, PhotoBlock, Text

Instance Method Summary collapse

Instance Method Details

#BreakObject



5
6
7
# File 'lib/fn/swf/node/break.rb', line 5

def Break
  FN::Node::Base("break").extend(Break)
end

#Flash(width, height) ⇒ Object



5
6
7
# File 'lib/fn/swf/node/flash.rb', line 5

def Flash(width, height)
  FN::Node::Base("flash", :width => width, :height => height).extend(Flash)
end

#Font(name, file) ⇒ Object



6
7
8
# File 'lib/fn/swf/node/font.rb', line 6

def Font(name, file)
  FN::Node::Base("font", :name => name, :file => file).extend(Font)
end

#Frame(name, file) ⇒ Object



5
6
7
# File 'lib/fn/swf/node/frame.rb', line 5

def Frame(name, file)
  FN::Node::Base("frame", :name => name, :file => file).extend(Frame)
end

#HotSpot(page) ⇒ Object



5
6
7
8
9
10
# File 'lib/fn/swf/node/hot_spot.rb', line 5

def HotSpot(page)
  x, y, x2, y2 = page[:hotspot].gsub(/\s/, '').split(",").map{|s| s.to_i}
  w = x2 - x
  h = y2 - y
  FN::Node::Base("hot_spot", :x => x, :y => y, :w => w, :h => h, :n => page[:number]).extend(HotSpot)
end

#Image(name, file) ⇒ Object



5
6
7
# File 'lib/fn/swf/node/image.rb', line 5

def Image(name, file)
  FN::Node::Base("image", :name => name, :file => file).extend(Image)
end

#Page(number, bkg) ⇒ Object



6
7
8
# File 'lib/fn/swf/node/page.rb', line 6

def Page(number, bkg)
  FN::Node::Base("page", :number => number, :bkg => bkg).extend(Page)
end

#PhotoBlock(node, image_dims = {}) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fn/swf/node/photo_block.rb', line 6

def PhotoBlock(node, image_dims = {})
  dims = image_dims[node[:src]]
  FN::Node::Base("photo_block", node.attributes.to_h.update(
    :orig_width => dims[0],
    :orig_height => dims[1]
  )).extend(PhotoBlock)
end

#Text(node, alt_text) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fn/swf/node/text.rb', line 5

def Text(node, alt_text)
  out = FN::Node::Base("text", node.attributes.to_h)
  out.extend(Text)
  out.text = node.children.to_s
  out.text = alt_text                  if out.text.empty?
  out
end