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.
-
#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_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 |
# File 'lib/libring/event.rb', line 7 def initialize(date) @date = DateTime.parse(date) @invitees = [] @metadata = {} @products = {} @source = "" @source_referral = "" @page_title = "" @ip = "" 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 |
#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
63 64 65 66 67 68 69 |
# File 'lib/libring/event.rb', line 63 def add_invitee(name) @invitees.push(name) true end |
#add_metadata(name, value) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/libring/event.rb', line 79 def (name, value) @metadata[name] = value true end |
#add_product(product) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/libring/event.rb', line 95 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 true else "Product unit amount required" end end |
#clean_invitees ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/libring/event.rb', line 71 def clean_invitees @invitees = [] true end |
#clean_metadata ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/libring/event.rb', line 87 def @metadata = {} true end |
#clean_products ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/libring/event.rb', line 114 def clean_products @products = {} true end |
#set_ip(data) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/libring/event.rb', line 47 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
39 40 41 42 43 44 45 |
# File 'lib/libring/event.rb', line 39 def set_page_title(data) @page_title = data true end |
#set_source(data) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/libring/event.rb', line 23 def set_source(data) @source = data true end |
#set_source_referral(data) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/libring/event.rb', line 31 def set_source_referral(data) @source_referral = data true end |