Class: TF2R::Raffle
Overview
This class provides a simple wrapper around grabbing information for a raffle from the Scraper and API. TODO: document
Instance Attribute Summary collapse
-
#link_snippet ⇒ Object
readonly
Returns the value of attribute link_snippet.
Instance Method Summary collapse
-
#creator ⇒ Object
Gives information about the raffle’s creator.
-
#info ⇒ Hash
Gives information about the raffle.
-
#initialize(link_snippet) ⇒ Raffle
constructor
A new instance of Raffle.
-
#participants ⇒ Object
TODO: test raffles with max_entries greater than 2500.
Methods included from TextHelpers
#extract_color, #extract_link_snippet, #extract_steam_id, #raffle_link, #raffle_link_full, #user_link
Constructor Details
#initialize(link_snippet) ⇒ Raffle
Returns a new instance of Raffle.
10 11 12 13 14 15 16 |
# File 'lib/tf2r/raffle.rb', line 10 def initialize(link_snippet) @link_snippet = link_snippet @scraper = Scraper.new populate_raffle_info get_full_participants if max_entries > API::MAX_ENTRY_RESPONSE_COUNT end |
Instance Attribute Details
#link_snippet ⇒ Object (readonly)
Returns the value of attribute link_snippet.
8 9 10 |
# File 'lib/tf2r/raffle.rb', line 8 def link_snippet @link_snippet end |
Instance Method Details
#creator ⇒ Object
Gives information about the raffle’s creator.
Taken straight from Scraper
.
59 60 61 |
# File 'lib/tf2r/raffle.rb', line 59 def creator @scraper_info[1] end |
#info ⇒ Hash
Gives information about the raffle.
46 47 48 49 50 51 52 |
# File 'lib/tf2r/raffle.rb', line 46 def info @info ||= {link_snippet: @link_snippet, title: title, description: description, start_time: start_time, end_time: end_time, win_chance: win_chance, current_entries: current_entries, max_entries: max_entries, is_done: is_done} end |
#participants ⇒ Object
TODO: test raffles with max_entries greater than 2500
64 65 66 67 68 69 70 |
# File 'lib/tf2r/raffle.rb', line 64 def participants if max_entries > API::MAX_ENTRY_RESPONSE_COUNT @full_participants else @normalized_participants ||= normalize_entries(@api_info['newentry']) end end |