Sha256: 5cf71350dd95d55a1af91c3cb96a691c1a3314e0f82e19e639375bd35440b657
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'observer' module Weskit::WML class Attribute < Item include Observable attachable_to :element attr_reader :value def code= bool @code = bool ? (@translatable = false ; true) : false end def code? @code end def multiline? "#{value}".include? "\n" end def text? code? or multiline? or translatable? end def translatable= bool @translatable = bool ? (@code = false ; true) : false end def translatable? @translatable end def initialize name, value, defaults = {} @code = @translatable = false self.name = name self.value = value merge defaults end def value= object @value = convert object end private def convert object string = object.to_s.strip object = case string when %r{^nil|null$} then nil when %r{^true|yes$} then true when %r{^false|no$} then false when %r{^[0-9]*\.[0-9]+$} then Float string when %r{^[0-9]+$} then Integer string else string end object.attr = self ; object end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
weskit-0.1.0 | lib/weskit/wml/attribute.rb |