class Vkdonate::Donate
Single donation
Attributes
@return [Boolean] Whether donation is anonymous
@return [Boolean] Whether donation is anonymous
@return [DateTime] Date and time of donation
@return [Integer] Unique payment ID
@return [String] User message or nil
if empty
@return [String] User message or nil
if empty
@return [Integer] Size of donation
@return [Integer] Donator VK ID
@return [Boolean] Whether donate is visible in group
@return [Boolean] Whether donate is visible in group
Public Class Methods
Parse from JSON hash. @param hash [Hash] parsed JSON hash. @return [Donate]
# 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
Save data about donation. @param options [Hash] @option options [Integer] id @option options [Integer] uid @option options [DateTime] date @option options [Integer] sum @option options [String] msg @option options [Boolean] anon @option options [Boolean] visible
# 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
Public Instance Methods
@return [String] Human readable information
# File lib/vkdonate/donate.rb, line 65 def to_s "Donation ##{id} by @#{uid} for #{sum}RUR (at #{date})" end