class DailyRep::Entities::Yanoil

Attributes

change[R]

Public Class Methods

create() click to toggle source
# File lib/dailyrep/entities/Yanoil.rb, line 8
def self.create
    result = [(new )]
end
new( delta=Configer.yanoil_delta, source=Configer.yanoil_source) click to toggle source
Calls superclass method DailyRep::IBrowser::new
# File lib/dailyrep/entities/Yanoil.rb, line 12
def initialize( delta=Configer.yanoil_delta, source=Configer.yanoil_source)
  super
  @search_path   = source
  @notif_limit   = delta
  @scope         = '.b-quote__last-day'
  @is_current_date = false
  @push = 0
end

Public Instance Methods

log_msg(phase) click to toggle source
Calls superclass method DailyRep::Trackable#log_msg
# File lib/dailyrep/entities/Yanoil.rb, line 21
def log_msg phase
  super @entity, phase
end
notify() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Yanoil.rb, line 41
def notify
  super do
    if @push == 1 then
      note = "Yandex Brent Oil
  Last value: #{@last}
  Delta percentage: #{@change}"
      push_note note
    end
  end
end
process() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Yanoil.rb, line 25
def process
  super do
    out_set        = get_source_http @search_path, @scope
    @last         = out_set.css('.b-quote__value').text.gsub(',','.').to_f
    v_date         = out_set.css('.b-quote__date').text
    change         = out_set.css('.b-quote__change').text.gsub(',','.')
    change_sign    = out_set.css('.b-quote__change .b-quote__sgn').text
    @change        = (change + change_sign).to_f
    @is_current_date = (Time.now.day.to_i == v_date[0..2].to_i)
    if @is_current_date then
      @push = track_change @change, @notif_limit
    end
  end
end
web_reload() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Yanoil.rb, line 59
def web_reload
  super do
    set_html @entity, { delta: @change, current: @last }
  end
end
write_to_db() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Yanoil.rb, line 53
def write_to_db
  super do
    write_hist @entity, :delta.to_s, @change, @push
  end
end