Class: Libring::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/libring/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/libring/event.rb', line 3

def date
  @date
end

#inviteesObject (readonly)

Returns the value of attribute invitees.



3
4
5
# File 'lib/libring/event.rb', line 3

def invitees
  @invitees
end

#ipObject (readonly)

Returns the value of attribute ip.



3
4
5
# File 'lib/libring/event.rb', line 3

def ip
  @ip
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/libring/event.rb', line 3

def 
  @metadata
end

#page_titleObject (readonly)

Returns the value of attribute page_title.



3
4
5
# File 'lib/libring/event.rb', line 3

def page_title
  @page_title
end

#productsObject (readonly)

Returns the value of attribute products.



3
4
5
# File 'lib/libring/event.rb', line 3

def products
  @products
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/libring/event.rb', line 3

def source
  @source
end

#source_referralObject (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_inviteesObject



71
72
73
74
75
76
77
# File 'lib/libring/event.rb', line 71

def clean_invitees

  @invitees = []

  true

end

#clean_metadataObject



87
88
89
90
91
92
93
# File 'lib/libring/event.rb', line 87

def 

  @metadata = {}

  true

end

#clean_productsObject



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