Sha256: 1f12e533969c1a0485d0c0f0cf08e39ac85fafd19f463d26a706f16a6a411437

Contents?: true

Size: 868 Bytes

Versions: 9

Compression:

Stored size: 868 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

9 entries across 9 versions & 1 rubygems

Version Path
RUIC-0.4.1 lib/ruic/interfaces.rb
RUIC-0.4.0 lib/ruic/interfaces.rb
RUIC-0.3.0 lib/ruic/interfaces.rb
RUIC-0.2.6 lib/ruic/interfaces.rb
RUIC-0.2.5 lib/ruic/interfaces.rb
RUIC-0.2.3 lib/ruic/interfaces.rb
RUIC-0.2.2 lib/ruic/interfaces.rb
RUIC-0.2.0 lib/ruic/interfaces.rb
RUIC-0.1.0 lib/ruic/interfaces.rb