Class: Libring::Event
- Inherits:
-
Object
- Object
- Libring::Event
- Defined in:
- lib/libring/event.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#event_code ⇒ Object
readonly
Returns the value of attribute event_code.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#expire_at ⇒ Object
readonly
Returns the value of attribute expire_at.
-
#invitees ⇒ Object
readonly
Returns the value of attribute invitees.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#page_title ⇒ Object
readonly
Returns the value of attribute page_title.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_referral ⇒ Object
readonly
Returns the value of attribute source_referral.
Instance Method Summary collapse
- #add_invitee(name) ⇒ Object
- #add_metadata(name, value) ⇒ Object
- #add_product(product) ⇒ Object
- #clean_invitees ⇒ Object
- #clean_metadata ⇒ Object
- #clean_products ⇒ Object
-
#initialize(date) ⇒ Event
constructor
A new instance of Event.
- #set_event_code(data) ⇒ Object
- #set_event_type(data) ⇒ Object
- #set_expire_at(data) ⇒ Object
- #set_ip(data) ⇒ Object
- #set_page_title(data) ⇒ Object
- #set_source(data) ⇒ Object
- #set_source_referral(data) ⇒ Object
Constructor Details
#initialize(date) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/libring/event.rb', line 7 def initialize(date) @date = DateTime.parse(date) @invitees = [] @metadata = {} @products = {} @source = "" @source_referral = "" @page_title = "" @ip = "" @expire_at = "" @event_type = "" @event_code = "" true end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def date @date end |
#event_code ⇒ Object (readonly)
Returns the value of attribute event_code.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def event_code @event_code end |
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def event_type @event_type end |
#expire_at ⇒ Object (readonly)
Returns the value of attribute expire_at.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def expire_at @expire_at end |
#invitees ⇒ Object (readonly)
Returns the value of attribute invitees.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def invitees @invitees end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def ip @ip end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def @metadata end |
#page_title ⇒ Object (readonly)
Returns the value of attribute page_title.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def page_title @page_title end |
#products ⇒ Object (readonly)
Returns the value of attribute products.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def products @products end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def source @source end |
#source_referral ⇒ Object (readonly)
Returns the value of attribute source_referral.
3 4 5 |
# File 'lib/libring/event.rb', line 3 def source_referral @source_referral end |
Instance Method Details
#add_invitee(name) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/libring/event.rb', line 90 def add_invitee(name) @invitees.push(name) true end |
#add_metadata(name, value) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/libring/event.rb', line 106 def (name, value) @metadata[name] = value true end |
#add_product(product) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/libring/event.rb', line 122 def add_product(product) if product.unit_amount != -1 @products["#{product.sku}"] = {} @products["#{product.sku}"][:name] = product.name @products["#{product.sku}"][:unit_amount] = product.unit_amount @products["#{product.sku}"][:quantity] = product.quantity @products["#{product.sku}"][:category] = product.category true else "Product unit amount required" end end |
#clean_invitees ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/libring/event.rb', line 98 def clean_invitees @invitees = [] true end |
#clean_metadata ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/libring/event.rb', line 114 def @metadata = {} true end |
#clean_products ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/libring/event.rb', line 142 def clean_products @products = {} true end |
#set_event_code(data) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/libring/event.rb', line 34 def set_event_code(data) @event_code = data true end |
#set_event_type(data) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/libring/event.rb', line 26 def set_event_type(data) @event_type = data true end |
#set_expire_at(data) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/libring/event.rb', line 42 def set_expire_at(data) @expire_at = data true end |
#set_ip(data) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/libring/event.rb', line 74 def set_ip(data) if /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/.match(data) @ip = data true else "Invalid IP" end end |
#set_page_title(data) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/libring/event.rb', line 66 def set_page_title(data) @page_title = data true end |
#set_source(data) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/libring/event.rb', line 50 def set_source(data) @source = data true end |
#set_source_referral(data) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/libring/event.rb', line 58 def set_source_referral(data) @source_referral = data true end |