Module: Yfinrb::Holders

Extended by:
ActiveSupport::Concern
Included in:
Ticker
Defined in:
lib/yfinrb/holders.rb

Constant Summary collapse

BASE_URL =

include YfConnection

'https://query2.finance.yahoo.com'.freeze
QUOTE_SUMMARY_URL =
"#{BASE_URL}/v10/finance/quoteSummary/".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

attr_accessor :ticker



11
12
13
14
15
16
17
18
19
# File 'lib/yfinrb/holders.rb', line 11

def self.included(base) # built-in Ruby hook for modules
  base.class_eval do
    original_method = instance_method(:initialize)
    define_method(:initialize) do |*args, &block|
      original_method.bind(self).call(*args, &block)
      initialize_holders # (your module code here)
    end
  end
end

Instance Method Details

#initialize_holdersObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/yfinrb/holders.rb', line 21

def initialize_holders
  @major = nil
  @major_direct_holders = nil
  @institutional = nil
  @mutualfund = nil

  @insider_transactions = nil
  @insider_purchases = nil
  @insider_roster = nil
end

#insider_purchasesObject



58
59
60
61
# File 'lib/yfinrb/holders.rb', line 58

def insider_purchases
  _fetch_and_parse if @insider_purchases.nil? 
  return @insider_purchases
end

#insider_rosterObject Also known as: insider_roster_holders



63
64
65
66
67
68
# File 'lib/yfinrb/holders.rb', line 63

def insider_roster
  return @insider_roster unless @insider_roster.nil? 

  _fetch_and_parse
  return @insider_roster
end

#insider_transactionsObject



53
54
55
56
# File 'lib/yfinrb/holders.rb', line 53

def insider_transactions
  _fetch_and_parse if @insider_transactions.nil? 
  return @insider_transactions
end

#institutionalObject Also known as: institutional_holders



39
40
41
42
# File 'lib/yfinrb/holders.rb', line 39

def institutional
  _fetch_and_parse if @institutional.nil? 
  return @institutional
end

#majorObject Also known as: major_holders



32
33
34
35
# File 'lib/yfinrb/holders.rb', line 32

def major
  _fetch_and_parse if @major.nil?
  return @major
end

#mutualfundObject Also known as: mutualfund_holders



46
47
48
49
# File 'lib/yfinrb/holders.rb', line 46

def mutualfund
  _fetch_and_parse if @mutualfund.nil? 
  return @mutualfund
end