Sha256: 8850954218bc4d34a8548db4387bd42eade4978855bdcd012ae9fa007364f853

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

module Intersail
  module Rpdf
    class Node
      def name
        @name
      end
      def children
        @children
      end
      def has_children?
        @children && @children.respond_to?(:length) && @children.length>0
      end

      def [](index)
        @hash[index]
      end
      
      def initialize(hash)
        @hash = hash

        @name = hash[:name]

        subtags = hash[:childs][:tag_node] if hash[:childs] && hash[:childs][:tag_node]

        if subtags.kind_of? Array
          @children = subtags.map{|c| Node.new(c)}
        elsif subtags.kind_of? Hash
          @children = [Node.new(subtags)]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpdf-0.9.7 lib/rpdf/models/node.rb
rpdf-0.9.6 lib/rpdf/models/node.rb