Class: SpreeCmCommissioner::Integrations::StadiumXV1::Resources::Match
- Defined in:
- app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb
Instance Attribute Summary collapse
-
#_id ⇒ Object
Returns the value of attribute _id.
-
#allow_predition ⇒ Object
Returns the value of attribute allow_predition.
-
#away_logo ⇒ Object
Returns the value of attribute away_logo.
-
#away_name ⇒ Object
Returns the value of attribute away_name.
-
#away_score ⇒ Object
Returns the value of attribute away_score.
-
#club_id ⇒ Object
Returns the value of attribute club_id.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#date ⇒ Object
Returns the value of attribute date.
-
#discount_ticket ⇒ Object
Returns the value of attribute discount_ticket.
-
#file ⇒ Object
Returns the value of attribute file.
-
#home_logo ⇒ Object
Returns the value of attribute home_logo.
-
#home_name ⇒ Object
Returns the value of attribute home_name.
-
#home_score ⇒ Object
Returns the value of attribute home_score.
-
#is_ended ⇒ Object
Returns the value of attribute is_ended.
-
#league ⇒ Object
Returns the value of attribute league.
-
#league_id ⇒ Object
Returns the value of attribute league_id.
-
#on_sale ⇒ Object
Returns the value of attribute on_sale.
-
#poster ⇒ Object
Returns the value of attribute poster.
-
#promotion ⇒ Object
Returns the value of attribute promotion.
-
#stadium ⇒ Object
Returns the value of attribute stadium.
-
#time ⇒ Object
Returns the value of attribute time.
-
#updated_by ⇒ Object
Returns the value of attribute updated_by.
-
#week ⇒ Object
Returns the value of attribute week.
-
#zones ⇒ Object
Returns the value of attribute zones.
Instance Method Summary collapse
- #display_match_datetime ⇒ Object
-
#initialize(attributes = {}) ⇒ Match
constructor
A new instance of Match.
- #match_datetime ⇒ Object
- #meta_description ⇒ Object
- #meta_title ⇒ Object
- #to_h ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attributes = {}) ⇒ Match
Returns a new instance of Match.
29 30 31 32 33 34 35 36 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 29 def initialize(attributes = {}) super(attributes) @on_sale = attributes['on_sale'] != false @is_ended = attributes['is_ended'] == true || attributes['is_ended'] == 'true' @allow_predition = attributes['allow_predition'] == true || attributes['allow_predition'] == 'true' @league = League.new(attributes['league']) if attributes['league'].is_a?(Hash) end |
Instance Attribute Details
#_id ⇒ Object
Returns the value of attribute _id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def _id @_id end |
#allow_predition ⇒ Object
Returns the value of attribute allow_predition.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def allow_predition @allow_predition end |
#away_logo ⇒ Object
Returns the value of attribute away_logo.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def away_logo @away_logo end |
#away_name ⇒ Object
Returns the value of attribute away_name.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def away_name @away_name end |
#away_score ⇒ Object
Returns the value of attribute away_score.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def away_score @away_score end |
#club_id ⇒ Object
Returns the value of attribute club_id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def club_id @club_id end |
#created_by ⇒ Object
Returns the value of attribute created_by.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def created_by @created_by end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def date @date end |
#discount_ticket ⇒ Object
Returns the value of attribute discount_ticket.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def discount_ticket @discount_ticket end |
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def file @file end |
#home_logo ⇒ Object
Returns the value of attribute home_logo.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def home_logo @home_logo end |
#home_name ⇒ Object
Returns the value of attribute home_name.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def home_name @home_name end |
#home_score ⇒ Object
Returns the value of attribute home_score.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def home_score @home_score end |
#is_ended ⇒ Object
Returns the value of attribute is_ended.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def is_ended @is_ended end |
#league ⇒ Object
Returns the value of attribute league.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def league @league end |
#league_id ⇒ Object
Returns the value of attribute league_id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def league_id @league_id end |
#on_sale ⇒ Object
Returns the value of attribute on_sale.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def on_sale @on_sale end |
#poster ⇒ Object
Returns the value of attribute poster.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def poster @poster end |
#promotion ⇒ Object
Returns the value of attribute promotion.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def promotion @promotion end |
#stadium ⇒ Object
Returns the value of attribute stadium.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def stadium @stadium end |
#time ⇒ Object
Returns the value of attribute time.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def time @time end |
#updated_by ⇒ Object
Returns the value of attribute updated_by.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def updated_by @updated_by end |
#week ⇒ Object
Returns the value of attribute week.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def week @week end |
#zones ⇒ Object
Returns the value of attribute zones.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 4 def zones @zones end |
Instance Method Details
#display_match_datetime ⇒ Object
53 54 55 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 53 def display_match_datetime match_datetime&.strftime('%B %d, %Y at %I:%M %p') end |
#match_datetime ⇒ Object
57 58 59 60 61 62 63 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 57 def match_datetime return nil unless @date && @time Time.zone.parse("#{@date} #{@time}") rescue StandardError nil end |
#meta_description ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 44 def return nil if home_name.blank? || away_name.blank? location = stadium.present? ? " at #{stadium}" : '' league_info = league&.name.present? ? " - #{league.name}" : '' "#{home_name} vs #{away_name}#{league_info} on #{display_match_datetime}#{location}. Book tickets now!" end |
#meta_title ⇒ Object
38 39 40 41 42 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 38 def return nil if home_name.blank? || away_name.blank? "#{home_name} vs #{away_name} - #{display_match_datetime}" end |
#to_h ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/services/spree_cm_commissioner/integrations/stadium_x_v1/resources/match.rb', line 65 def to_h { _id: _id, home_name: home_name, home_logo: home_logo, away_name: away_name, away_logo: away_logo, home_score: home_score, away_score: away_score, date: date, time: time, stadium: stadium, week: week, league_id: league_id, club_id: club_id, discount_ticket: discount_ticket, on_sale: on_sale, is_ended: is_ended, allow_predition: allow_predition, file: file, created_by: created_by, updated_by: updated_by, zones: zones&.map(&:to_h), promotion: promotion, poster: poster, league: league&.to_h }.compact end |