Sha256: a967cc188f2a74c1a9b5704555dbd96e300c4cc9e551a26374d416163ea1a77a
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 KB
Contents
module Weskit::WML class Attribute < Item 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
6 entries across 6 versions & 1 rubygems