Class: Dommy::HTMLMeterElement

Inherits:
HTMLElement show all
Defined in:
lib/dommy/html_elements.rb

Overview

‘<meter>` — gauge with `value` / `min` / `max` (default 0/0/1) plus `low` / `high` / `optimum`. All numeric; `labels` via the standard `<label for=“…”>` association.

Constant Summary

Constants inherited from Element

Element::ATTRIBUTE_NODE, Element::CDATA_SECTION_NODE, Element::COMMENT_NODE, Element::DOCUMENT_FRAGMENT_NODE, Element::DOCUMENT_NODE, Element::DOCUMENT_POSITION_CONTAINED_BY, Element::DOCUMENT_POSITION_CONTAINS, Element::DOCUMENT_POSITION_DISCONNECTED, Element::DOCUMENT_POSITION_FOLLOWING, Element::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Element::DOCUMENT_POSITION_PRECEDING, Element::DOCUMENT_TYPE_NODE, Element::ELEMENT_NODE, Element::PROCESSING_INSTRUCTION_NODE, Element::SHADOW_HOST_TAGS, Element::TEXT_NODE

Constants included from Node

Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_POSITION_CONTAINED_BY, Node::DOCUMENT_POSITION_CONTAINS, Node::DOCUMENT_POSITION_DISCONNECTED, Node::DOCUMENT_POSITION_FOLLOWING, Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Node::DOCUMENT_POSITION_PRECEDING, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE

Instance Attribute Summary

Attributes inherited from Element

#__node__, #document

Instance Method Summary collapse

Methods inherited from Element

#[], #[]=, #__js_call__, #__shadow_root__, #after, #anchor_href, #append, #append_child, #attach_shadow, #attributes, #base_uri, #before, #blur, #child_element_count, #child_nodes, #children, #class_list, #class_name, #class_name=, #click, #clone_node, #closest, #compare_document_position, #contains?, #dataset, #equal_node?, #first_child, #first_element_child, #focus, #get_attribute, #get_attribute_node, #get_elements_by_class_name, #get_elements_by_tag_name, #get_html, #get_inner_html, #has_attribute?, #has_attributes?, #has_child_nodes?, #id, #id=, #initialize, #inner_html, #inner_html=, #insert_adjacent_element, #insert_adjacent_html, #insert_adjacent_text, #insert_before, #is_connected?, #last_child, #last_element_child, #live_child_nodes, #local_name, #matches?, #namespace_uri, #next_element_sibling, #next_sibling, #normalize, #on, #outer_html, #outer_html=, #owner_document, #parent_element, #parent_node, #prepend, #previous_element_sibling, #previous_sibling, #query_selector, #query_selector_all, #reflected_attr_name, #remove, #remove_attribute, #remove_attribute_node, #remove_child, #replace_child, #replace_children, #replace_with_nodes, #role, #role=, #root_node, #same_node?, #set_attribute, #set_attribute_node, #shadow_root, #slot, #slot=, #style, #tag_name, #text_content, #text_content=, #to_s, #toggle_attribute

Methods included from EventTarget

#__deliver_event__, #add_event_listener, #dispatch_event, #invoke_listener, #remove_event_listener

Constructor Details

This class inherits a constructor from Dommy::Element

Instance Method Details

#__js_get__(key) ⇒ Object



2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
# File 'lib/dommy/html_elements.rb', line 2537

def __js_get__(key)
  case key
  when "value"
    value
  when "min"
    min
  when "max"
    max
  when "low"
    low
  when "high"
    high
  when "optimum"
    optimum
  when "labels"
    labels
  else
    super
  end
end

#__js_set__(key, v) ⇒ Object



2558
2559
2560
2561
2562
2563
2564
2565
# File 'lib/dommy/html_elements.rb', line 2558

def __js_set__(key, v)
  case key
  when "value", "min", "max", "low", "high", "optimum"
    set_reflected_string(key, v.to_s)
  else
    super
  end
end

#highObject



2515
2516
2517
# File 'lib/dommy/html_elements.rb', line 2515

def high
  numeric_attr("high", max)
end

#high=(v) ⇒ Object



2519
2520
2521
# File 'lib/dommy/html_elements.rb', line 2519

def high=(v)
  set_reflected_string("high", v.to_s)
end

#labelsObject



2531
2532
2533
2534
2535
# File 'lib/dommy/html_elements.rb', line 2531

def labels
  return [] if id.empty?

  @document.query_selector_all("label[for='#{id}']")
end

#lowObject



2507
2508
2509
# File 'lib/dommy/html_elements.rb', line 2507

def low
  numeric_attr("low", min)
end

#low=(v) ⇒ Object



2511
2512
2513
# File 'lib/dommy/html_elements.rb', line 2511

def low=(v)
  set_reflected_string("low", v.to_s)
end

#maxObject



2499
2500
2501
# File 'lib/dommy/html_elements.rb', line 2499

def max
  numeric_attr("max", 1.0)
end

#max=(v) ⇒ Object



2503
2504
2505
# File 'lib/dommy/html_elements.rb', line 2503

def max=(v)
  set_reflected_string("max", v.to_s)
end

#minObject



2491
2492
2493
# File 'lib/dommy/html_elements.rb', line 2491

def min
  numeric_attr("min", 0.0)
end

#min=(v) ⇒ Object



2495
2496
2497
# File 'lib/dommy/html_elements.rb', line 2495

def min=(v)
  set_reflected_string("min", v.to_s)
end

#optimumObject



2523
2524
2525
# File 'lib/dommy/html_elements.rb', line 2523

def optimum
  numeric_attr("optimum", (min + max) / 2.0)
end

#optimum=(v) ⇒ Object



2527
2528
2529
# File 'lib/dommy/html_elements.rb', line 2527

def optimum=(v)
  set_reflected_string("optimum", v.to_s)
end

#valueObject



2483
2484
2485
# File 'lib/dommy/html_elements.rb', line 2483

def value
  numeric_attr("value", 0.0)
end

#value=(v) ⇒ Object



2487
2488
2489
# File 'lib/dommy/html_elements.rb', line 2487

def value=(v)
  set_reflected_string("value", v.to_s)
end