Sha256: 4b8916d11163c275f0281ec5bb8de545342001841db2122ea5e6fdca4c924081

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Spread2RDF
  class Spreadsheet
    class Element
      include Attributes

      self.attributes = {
          name:         nil,
          source_name:  nil
      }

      attr_reader :parent
      attr_reader :block


      def initialize(parent, attr={}, &block)
        @parent   = parent
        @block    = block
        init_attributes(attr)
      end

      def init

      end

      def name
        (@name or @source_name).try(:to_sym)
      end

      def source_name
        (@source_name or @name).try(:to_s)
      end

      def spreadsheet
        parent.spreadsheet
      end

      def to_s
        name = (self.name.to_s == self.source_name.to_s ?
            self.name : "#{self.name} (#{self.source_name})" )
        "#{self.class.name.split('::').last} #{name}"
      end

    private

      def create_context(parent_context, attr)
        context_class = self.class.const_get(:MappingContext)
        context_class.new(self, parent_context, attr)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spread2rdf-0.0.1pre.1 lib/spread2rdf/spreadsheet/element.rb