class Postal::AddressFormatter::HTML
Constants
- ItemProp
- Schema
Public Instance Methods
render(params={})
click to toggle source
Calls superclass method
# File lib/postal_address/formatters/html.rb, line 14 def render(params={}) content_tag((params.delete(:tag) || :p), super.gsub("\n", "<br>"), params.merge(itemscope: nil, itemtype: Schema)) end
Private Instance Methods
address_data()
click to toggle source
Calls superclass method
# File lib/postal_address/formatters/html.rb, line 20 def address_data super.each_with_object({}) do |(field, value), hash| hash[field] = value && content_tag(:span, value, itemprop: ItemProp[field]) end end
content_tag(tag, content='', attrs={})
click to toggle source
# File lib/postal_address/formatters/html.rb, line 26 def content_tag(tag, content='', attrs={}) "<#{tag}#{tag_attributes(attrs)}>#{content}</#{tag}>" end
tag_attributes(attrs)
click to toggle source
# File lib/postal_address/formatters/html.rb, line 30 def tag_attributes(attrs) attrs.map { |k,v| v ? %[#{k}="#{v}"] : k }.unshift('').join(' ') end