class Vkdonate::Donate

Single donation

Attributes

anon[R]

@return [Boolean] Whether donation is anonymous

anon?[R]

@return [Boolean] Whether donation is anonymous

date[R]

@return [DateTime] Date and time of donation

id[R]

@return [Integer] Unique payment ID

message[R]

@return [String] User message or nil if empty

msg[R]

@return [String] User message or nil if empty

sum[R]

@return [Integer] Size of donation

uid[R]

@return [Integer] Donator VK ID

visible[R]

@return [Boolean] Whether donate is visible in group

visible?[R]

@return [Boolean] Whether donate is visible in group

Public Class Methods

from_json(hash) click to toggle source

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
new(id:, uid:, date:, sum:, msg:, anon:, visible:) click to toggle source

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

to_s() click to toggle source

@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