Class: SecEdgar::OwnershipDocument

Inherits:
Struct
  • Object
show all
Defined in:
lib/sec_edgar/ownership_document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#derivative_transactionsObject

Returns the value of attribute derivative_transactions

Returns:

  • (Object)

    the current value of derivative_transactions



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def derivative_transactions
  @derivative_transactions
end

#document_typeObject

Returns the value of attribute document_type

Returns:

  • (Object)

    the current value of document_type



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def document_type
  @document_type
end

#footnotesObject

Returns the value of attribute footnotes

Returns:

  • (Object)

    the current value of footnotes



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def footnotes
  @footnotes
end

#is_directorObject

Returns the value of attribute is_director

Returns:

  • (Object)

    the current value of is_director



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def is_director
  @is_director
end

#is_officerObject

Returns the value of attribute is_officer

Returns:

  • (Object)

    the current value of is_officer



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def is_officer
  @is_officer
end

#is_otherObject

Returns the value of attribute is_other

Returns:

  • (Object)

    the current value of is_other



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def is_other
  @is_other
end

#is_ten_percent_ownerObject

Returns the value of attribute is_ten_percent_owner

Returns:

  • (Object)

    the current value of is_ten_percent_owner



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def is_ten_percent_owner
  @is_ten_percent_owner
end

#issuer_cikObject

Returns the value of attribute issuer_cik

Returns:

  • (Object)

    the current value of issuer_cik



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def issuer_cik
  @issuer_cik
end

#issuer_nameObject

Returns the value of attribute issuer_name

Returns:

  • (Object)

    the current value of issuer_name



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def issuer_name
  @issuer_name
end

#issuer_trading_symbolObject

Returns the value of attribute issuer_trading_symbol

Returns:

  • (Object)

    the current value of issuer_trading_symbol



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def issuer_trading_symbol
  @issuer_trading_symbol
end

#not_subject_to_section_16Object

Returns the value of attribute not_subject_to_section_16

Returns:

  • (Object)

    the current value of not_subject_to_section_16



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def not_subject_to_section_16
  @not_subject_to_section_16
end

#officer_titleObject

Returns the value of attribute officer_title

Returns:

  • (Object)

    the current value of officer_title



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def officer_title
  @officer_title
end

#owner_addressObject

Returns the value of attribute owner_address

Returns:

  • (Object)

    the current value of owner_address



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def owner_address
  @owner_address
end

#owner_cikObject

Returns the value of attribute owner_cik

Returns:

  • (Object)

    the current value of owner_cik



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def owner_cik
  @owner_cik
end

#owner_nameObject

Returns the value of attribute owner_name

Returns:

  • (Object)

    the current value of owner_name



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def owner_name
  @owner_name
end

#period_of_reportObject

Returns the value of attribute period_of_report

Returns:

  • (Object)

    the current value of period_of_report



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def period_of_report
  @period_of_report
end

#schema_versionObject

Returns the value of attribute schema_version

Returns:

  • (Object)

    the current value of schema_version



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def schema_version
  @schema_version
end

#transactionsObject

Returns the value of attribute transactions

Returns:

  • (Object)

    the current value of transactions



25
26
27
# File 'lib/sec_edgar/ownership_document.rb', line 25

def transactions
  @transactions
end

Instance Method Details

#all_transObject



78
79
80
# File 'lib/sec_edgar/ownership_document.rb', line 78

def all_trans
  trans + derivative_trans
end

#as_jsonObject



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/sec_edgar/ownership_document.rb', line 108

def as_json(*)
  tran_codes = {}

  SecEdgar::TRANSACTION_CODES.keys.each do |code|
    name = "per_code_#{ code.downcase }".to_sym
    tran_codes[name] = send(name)
  end

  super
    .merge(sum_shares: sum_shares, sum_shares_after: sum_shares_after)
    .merge(tran_codes)
end

#derivative_transObject



86
87
88
# File 'lib/sec_edgar/ownership_document.rb', line 86

def derivative_trans
  derivative_transactions || []
end

#dollar_volumeObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sec_edgar/ownership_document.rb', line 60

def dollar_volume
  @dollar_volume ||= begin
    sum = 0
    all_trans.each do |t|
      if t.acquired_or_disposed_code == 'A'
        sum += t.shares * t.price_per_share
      else
        sum -= t.shares * t.price_per_share
      end
    end
    sum
  end
end

#sum_sharesObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sec_edgar/ownership_document.rb', line 46

def sum_shares
  @sum ||= begin
    sum = 0
    all_trans.each do |t|
      if t.acquired_or_disposed_code == 'A'
        sum += t.shares
      else
        sum -= t.shares
      end
    end
    sum
  end
end

#sum_shares_afterObject



103
104
105
106
# File 'lib/sec_edgar/ownership_document.rb', line 103

def sum_shares_after
  return all_trans.map(&:shares_after).max if sum_shares > 0
  trans.map(&:shares_after).min || 0
end

#total_sharesObject



74
75
76
# File 'lib/sec_edgar/ownership_document.rb', line 74

def total_shares
  @total ||= all_trans.map(&:shares).inject(:+)
end

#transObject



82
83
84
# File 'lib/sec_edgar/ownership_document.rb', line 82

def trans
  transactions || []
end