Module: PostalAddress::InstanceMethods
- Included in:
- PostalAddress
- Defined in:
- lib/postal_address/instance_methods.rb
Instance Method Summary collapse
- #country ⇒ Object
- #country_code=(code) ⇒ Object
- #initialize(params = {}) ⇒ Object
- #to_h ⇒ Object
- #to_html(params = {}) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#country ⇒ Object
26 27 28 |
# File 'lib/postal_address/instance_methods.rb', line 26 def country @country = self.class.country_names[country_code] unless in_home_country? end |
#country_code=(code) ⇒ Object
22 23 24 |
# File 'lib/postal_address/instance_methods.rb', line 22 def country_code=(code) @country_code = code && code.to_s.downcase end |
#initialize(params = {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/postal_address/instance_methods.rb', line 3 def initialize(params={}) params.each do |attr, value| self.public_send("#{attr}=", value) if self.respond_to?("#{attr}=") end if params end |
#to_h ⇒ Object
9 10 11 |
# File 'lib/postal_address/instance_methods.rb', line 9 def to_h attributes end |
#to_html(params = {}) ⇒ Object
17 18 19 20 |
# File 'lib/postal_address/instance_methods.rb', line 17 def to_html(params={}) address = format(attributes(:html)).gsub("\n", "<br>") content_tag((params.delete(:tag) || :div), address, params.merge(itemscope: nil, itemtype: 'http://schema.org/PostalAddress')) end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/postal_address/instance_methods.rb', line 13 def to_s format(attributes) end |