Class: BetterSeo::StructuredData::LocalBusiness
- Defined in:
- lib/better_seo/structured_data/local_business.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#address(street: nil, city: nil, region: nil, postal_code: nil, country: nil) ⇒ Object
Address with PostalAddress schema.
-
#aggregate_rating(rating_value:, review_count:, best_rating: 5, worst_rating: 1) ⇒ Object
Aggregate rating.
- #description(value) ⇒ Object
- #email(value) ⇒ Object
-
#geo(latitude:, longitude:) ⇒ Object
Geographic coordinates.
- #image(value) ⇒ Object
-
#initialize(**properties) ⇒ LocalBusiness
constructor
A new instance of LocalBusiness.
-
#name(value) ⇒ Object
Basic properties.
-
#opening_hours(value) ⇒ Object
Opening hours - accepts string or array.
-
#opening_hours_specification(value) ⇒ Object
Opening hours specification (structured format).
- #price_range(value) ⇒ Object
-
#serves_cuisine(value) ⇒ Object
Serves cuisine (for restaurants).
- #telephone(value) ⇒ Object
- #url(value) ⇒ Object
Methods inherited from Base
#get, #set, #to_h, #to_json, #to_script_tag, #valid?, #validate!
Constructor Details
#initialize(**properties) ⇒ LocalBusiness
Returns a new instance of LocalBusiness.
6 7 8 |
# File 'lib/better_seo/structured_data/local_business.rb', line 6 def initialize(**properties) super("LocalBusiness", **properties) end |
Instance Method Details
#address(street: nil, city: nil, region: nil, postal_code: nil, country: nil) ⇒ Object
Address with PostalAddress schema
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/better_seo/structured_data/local_business.rb', line 40 def address(street: nil, city: nil, region: nil, postal_code: nil, country: nil) address_hash = { "@type" => "PostalAddress" } address_hash["streetAddress"] = street if street address_hash["addressLocality"] = city if city address_hash["addressRegion"] = region if region address_hash["postalCode"] = postal_code if postal_code address_hash["addressCountry"] = country if country set(:address, address_hash) end |
#aggregate_rating(rating_value:, review_count:, best_rating: 5, worst_rating: 1) ⇒ Object
Aggregate rating
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/better_seo/structured_data/local_business.rb', line 76 def (rating_value:, review_count:, best_rating: 5, worst_rating: 1) = { "@type" => "AggregateRating", "ratingValue" => , "reviewCount" => review_count, "bestRating" => , "worstRating" => } set(:aggregateRating, ) end |
#description(value) ⇒ Object
15 16 17 |
# File 'lib/better_seo/structured_data/local_business.rb', line 15 def description(value) set(:description, value) end |
#email(value) ⇒ Object
27 28 29 |
# File 'lib/better_seo/structured_data/local_business.rb', line 27 def email(value) set(:email, value) end |
#geo(latitude:, longitude:) ⇒ Object
Geographic coordinates
55 56 57 58 59 60 61 62 63 |
# File 'lib/better_seo/structured_data/local_business.rb', line 55 def geo(latitude:, longitude:) geo_hash = { "@type" => "GeoCoordinates", "latitude" => latitude, "longitude" => longitude } set(:geo, geo_hash) end |
#image(value) ⇒ Object
31 32 33 |
# File 'lib/better_seo/structured_data/local_business.rb', line 31 def image(value) set(:image, value) end |
#name(value) ⇒ Object
Basic properties
11 12 13 |
# File 'lib/better_seo/structured_data/local_business.rb', line 11 def name(value) set(:name, value) end |
#opening_hours(value) ⇒ Object
Opening hours - accepts string or array
66 67 68 |
# File 'lib/better_seo/structured_data/local_business.rb', line 66 def opening_hours(value) set(:openingHours, value) end |
#opening_hours_specification(value) ⇒ Object
Opening hours specification (structured format)
71 72 73 |
# File 'lib/better_seo/structured_data/local_business.rb', line 71 def opening_hours_specification(value) set(:openingHoursSpecification, value) end |
#price_range(value) ⇒ Object
35 36 37 |
# File 'lib/better_seo/structured_data/local_business.rb', line 35 def price_range(value) set(:priceRange, value) end |
#serves_cuisine(value) ⇒ Object
Serves cuisine (for restaurants)
89 90 91 |
# File 'lib/better_seo/structured_data/local_business.rb', line 89 def serves_cuisine(value) set(:servesCuisine, value) end |
#telephone(value) ⇒ Object
23 24 25 |
# File 'lib/better_seo/structured_data/local_business.rb', line 23 def telephone(value) set(:telephone, value) end |
#url(value) ⇒ Object
19 20 21 |
# File 'lib/better_seo/structured_data/local_business.rb', line 19 def url(value) set(:url, value) end |