Class: FunHtml::Attribute
- Inherits:
-
Object
- Object
- FunHtml::Attribute
- Includes:
- AttributeDefinitions
- Defined in:
- lib/fun_html.rb
Overview
nodoc
Class Method Summary collapse
-
.to_html(attr) ⇒ Object
only allow nil or objects that respond to ‘safe_attribute`.
Instance Method Summary collapse
-
#initialize(buffer = {}, &block) ⇒ Attribute
constructor
create a new Attribute object to create reuseable attributes.
-
#merge(other) ⇒ Object
merge two attribute sets together.
- #safe_attribute ⇒ Object
Methods included from AttributeDefinitions
#accept, #accept_charset, #accesskey, #action, #align, #alt, #async, #autocomplete, #autofocus, #autoplay, #bgcolor, #border, #charset, #checked, #cols, #colspan, #content, #contenteditable, #controls, #coords, #data, #datetime, #default, #defer, #dir, #disabled, #download, #draggable, #enctype, #for, #form, #formaction, #headers, #height, #hidden, #high, #href, #hreflang, #id, #integrity, #ismap, #kind, #klass, #label, #lang, #list, #loop, #low, #max, #maxlength, #media, #method, #min, #multiple, #muted, #name, #novalidate, #open, #optimum, #pattern, #placeholder, #poster, #preload, #readonly, #rel, #required, #reversed, #rows, #rowspan, #sandbox, #scope, #selected, #shape, #size, #sizes, #spellcheck, #src, #srcdoc, #srclang, #srcset, #start, #step, #style, #tabindex, #target, #title, #translate, #type, #usemap, #value, #width, #wrap
Constructor Details
#initialize(buffer = {}, &block) ⇒ Attribute
create a new Attribute object to create reuseable attributes
89 90 91 92 |
# File 'lib/fun_html.rb', line 89 def initialize(buffer = {}, &block) @__buffer = buffer instance_eval(&block) if block end |
Class Method Details
.to_html(attr) ⇒ Object
only allow nil or objects that respond to ‘safe_attribute`
84 85 86 |
# File 'lib/fun_html.rb', line 84 def self.to_html(attr) attr&.safe_attribute.to_s end |
Instance Method Details
#merge(other) ⇒ Object
merge two attribute sets together
95 96 97 |
# File 'lib/fun_html.rb', line 95 def merge(other) self.class.new(@__buffer.merge(other.instance_variable_get(:@__buffer))) end |
#safe_attribute ⇒ Object
99 100 101 |
# File 'lib/fun_html.rb', line 99 def safe_attribute @__buffer.values.join end |