Class: Motley::AttSet
Overview
Motley::AttSet
Instance Attribute Summary collapse
-
#dfns ⇒ Object
readonly
Returns the value of attribute dfns.
-
#vals ⇒ Object
readonly
Returns the value of attribute vals.
Instance Method Summary collapse
-
#[]=(key, val) ⇒ Object
————————————————————————— []=.
-
#initialize(dfns) ⇒ AttSet
constructor
————————————————————————— initialize.
Constructor Details
#initialize(dfns) ⇒ AttSet
initialize
57 58 59 60 |
# File 'lib/motley.rb', line 57 def initialize(dfns) @dfns = dfns @vals = {} end |
Instance Attribute Details
#dfns ⇒ Object (readonly)
Returns the value of attribute dfns.
47 48 49 |
# File 'lib/motley.rb', line 47 def dfns @dfns end |
#vals ⇒ Object (readonly)
Returns the value of attribute vals.
48 49 50 |
# File 'lib/motley.rb', line 48 def vals @vals end |
Instance Method Details
#[]=(key, val) ⇒ Object
[]=
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/motley.rb', line 69 def []=(key, val) # $tm.hrm # normalize key key = key.downcase # get att definition dfn = @dfns[key] # if no definition if not dfn exc = StandardError::Plus.new('/zax/attset/no-att-definition') exc['att'] = key raise exc end # XML and HTML do not have the concept of null, so if nil is assigned, # we delete the hash element. Else we set the value if val.nil? @vals.delete(key) else @vals[key] = dfn.set(val) end end |