Sha256: eaf4e9ba80490be4e19c24e93efb6005617c36f6467e11f004879469df0702f4

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

module UIC::FileBacked
	attr_accessor :doc, :file
	def path_to( relative )
		File.expand_path( relative.gsub('\\','/'), File.dirname(file) )
	end
	def filename
		File.basename(file)
	end
	def file_found?
		!@file_not_found
	end
	def file=( new_path )
		@file = File.expand_path(new_path)
		@file_not_found = !File.exist?(new_path)
		# warn "Could not find file '#{new_path}'" unless file_found?
	end
end

module UIC::ElementBacked
	attr_accessor :owner, :el
  def self.included(base)
    base.extend(ClassMethods)
  end
  module ClassMethods
		def xmlattribute(name,&block)
			define_method(name){ @el[name] }
			define_method("#{name}=", &(block || ->(new_value){ @el[name]=new_value.to_s }))
		end
  end	
end

module UIC::PresentableHash
	def to_s
		flat_map{ |k,v| [ k, *(v.is_a?(Array) ? v.map{|v2| "\t#{v2.to_s}" } : v) ] }
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
RUIC-0.0.1 lib/ruic/interfaces.rb