Class: Vkdonate::Donate
- Inherits:
-
Object
- Object
- Vkdonate::Donate
- Defined in:
- lib/vkdonate/donate.rb
Overview
Single donation
Instance Attribute Summary collapse
-
#anon ⇒ Boolean
(also: #anon?)
readonly
Whether donation is anonymous.
-
#date ⇒ DateTime
readonly
Date and time of donation.
-
#id ⇒ Integer
readonly
Unique payment ID.
-
#msg ⇒ String
(also: #message)
readonly
User message or
nil
if empty. -
#sum ⇒ Integer
readonly
Size of donation.
-
#uid ⇒ Integer
readonly
Donator VK ID.
-
#visible ⇒ Boolean
(also: #visible?)
readonly
Whether donate is visible in group.
Class Method Summary collapse
-
.from_json(hash) ⇒ Donate
Parse from JSON hash.
Instance Method Summary collapse
-
#initialize(id:, uid:, date:, sum:, msg:, anon:, visible:) ⇒ Donate
constructor
Save data about donation.
-
#to_s ⇒ String
Human readable information.
Constructor Details
#initialize(id:, uid:, date:, sum:, msg:, anon:, visible:) ⇒ Donate
Save data about donation.
39 40 41 42 43 44 45 46 47 |
# File 'lib/vkdonate/donate.rb', line 39 def initialize(id:, uid:, date:, sum:, msg:, anon:, visible:) @id = id @uid = uid @date = date @sum = sum @msg = msg @anon = anon @visible = visible end |
Instance Attribute Details
#anon ⇒ Boolean (readonly) Also known as: anon?
Returns Whether donation is anonymous.
23 24 25 |
# File 'lib/vkdonate/donate.rb', line 23 def anon @anon end |
#date ⇒ DateTime (readonly)
Returns Date and time of donation.
13 14 15 |
# File 'lib/vkdonate/donate.rb', line 13 def date @date end |
#id ⇒ Integer (readonly)
Returns Unique payment ID.
7 8 9 |
# File 'lib/vkdonate/donate.rb', line 7 def id @id end |
#msg ⇒ String (readonly) Also known as: message
Returns User message or nil
if empty.
19 20 21 |
# File 'lib/vkdonate/donate.rb', line 19 def msg @msg end |
#sum ⇒ Integer (readonly)
Returns Size of donation.
16 17 18 |
# File 'lib/vkdonate/donate.rb', line 16 def sum @sum end |
#uid ⇒ Integer (readonly)
Returns Donator VK ID.
10 11 12 |
# File 'lib/vkdonate/donate.rb', line 10 def uid @uid end |
#visible ⇒ Boolean (readonly) Also known as: visible?
Returns Whether donate is visible in group.
27 28 29 |
# File 'lib/vkdonate/donate.rb', line 27 def visible @visible end |
Class Method Details
.from_json(hash) ⇒ Donate
Parse from JSON hash.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vkdonate/donate.rb', line 52 def self.from_json(hash) new( id: hash['id'], uid: hash['uid'], date: DateTime.parse(hash['date'] + " #{TIME_OFFSET}"), sum: hash['sum'], msg: hash['msg'].to_s, anon: Integer(hash['anon'].to_s, 10) != 0, visible: Integer(hash['visible'].to_s, 10) != 0 ) end |
Instance Method Details
#to_s ⇒ String
Returns Human readable information.
65 66 67 |
# File 'lib/vkdonate/donate.rb', line 65 def to_s "Donation ##{id} by @#{uid} for #{sum}RUR (at #{date})" end |