class FilterMapper

Public Class Methods

new(*params) click to toggle source
# File lib/finviz_rails/filter_mapper.rb, line 2
def initialize(*params)
  @params = params.first
  @param_components = []
end

Public Instance Methods

run() click to toggle source
# File lib/finviz_rails/filter_mapper.rb, line 7
def run
  mapper.each do |key, value|
    @param_components << "#{value}_#{@params[key]}" if @params[key]
  end
  @param_components.join(",")
end

Private Instance Methods

mapper() click to toggle source
# File lib/finviz_rails/filter_mapper.rb, line 16
def mapper
  {
    price_range: "sh_price",
    analyst_recommendation: "an_recom",
    volatility: "ta_volatility",
    average_volume: "sh_avgvol",
    relative_volume: "sh_relvol",
    pattern: "ta_pattern",
    country: "geo",
    current_volume: "sh_curvol",
    simple_moving_average_20_day: "ta_sma20",
    simple_moving_average_50_day: "ta_sma50",
    simple_moving_average_200_day: "ta_sma200",
    current_ratio: "fa_curratio",
    performance: "ta_perf",
    sector: "sec",
    insider_ownership: "sh_insiderown",
    industry: "ind",
    insider_transactions: "sh_insidertrans",
    change: "ta_change",
    institutional_ownership: "sh_instown",
    gap: "ta_gap",
    change_from_open: "ta_changeopen",
    candlestick: "ta_candlestick",
    index: "idx"
  }
end