Class: HTML::Conditions
- Defined in:
- actionview/lib/action_view/vendor/html-scanner/html/node.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(hash) ⇒ Conditions
constructor
A new instance of Conditions.
Methods inherited from Hash
#as_json, #assert_valid_keys, #compact, #compact!, #deep_dup, #deep_merge, #deep_merge!, #deep_stringify_keys, #deep_stringify_keys!, #deep_symbolize_keys, #deep_symbolize_keys!, #deep_transform_keys, #deep_transform_keys!, #except, #except!, #extract!, #extractable_options?, from_trusted_xml, from_xml, #reverse_merge, #reverse_merge!, #slice, #slice!, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!, #to_query, #to_xml, #transform_keys, #transform_keys!, #with_indifferent_access
Constructor Details
#initialize(hash) ⇒ Conditions
Returns a new instance of Conditions.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'actionview/lib/action_view/vendor/html-scanner/html/node.rb', line 6 def initialize(hash) super() hash = { :content => hash } unless Hash === hash hash = keys_to_symbols(hash) hash.each do |k,v| case k when :tag, :content then # keys are valid, and require no further processing when :attributes then hash[k] = keys_to_strings(v) when :parent, :child, :ancestor, :descendant, :sibling, :before, :after hash[k] = Conditions.new(v) when :children hash[k] = v = keys_to_symbols(v) v.each do |key,value| case key when :count, :greater_than, :less_than # keys are valid, and require no further processing when :only v[key] = Conditions.new(value) else raise "illegal key #{key.inspect} => #{value.inspect}" end end else raise "illegal key #{k.inspect} => #{v.inspect}" end end update hash end |