class ThirteenF::Position

Attributes

cusip[R]
filing[R]
investment_discretion[R]
name_of_issuer[R]
other_managers[R]
put_or_call[R]
shares_or_principal_amount[R]
shares_or_principal_amount_type[R]
title_of_class[R]
value_in_thousands[R]
voting_authority[R]

Public Class Methods

from_xml_filing(filing) click to toggle source
# File lib/thirteen_f/position.rb, line 9
def self.from_xml_filing(filing)
  return nil unless filing.table_xml_url
  from_xml_url(filing.table_xml_url, filing: filing)
end
from_xml_url(table_xml_url, filing: nil) click to toggle source
# File lib/thirteen_f/position.rb, line 14
def self.from_xml_url(table_xml_url, filing: nil)
  xml_doc = SecRequest.get table_xml_url, response_type: :xml
  xml_doc.search("//infoTable").map do |info_table|
    position = new filing: filing
    position.attributes_from_info_table(info_table)
    position
  end
end
new(filing: nil) click to toggle source
# File lib/thirteen_f/position.rb, line 23
def initialize(filing: nil)
  @filing = filing
end

Public Instance Methods

attributes_from_info_table(info_table) click to toggle source
# File lib/thirteen_f/position.rb, line 27
def attributes_from_info_table(info_table)
  @name_of_issuer = info_table.search('nameOfIssuer').text
  @title_of_class = info_table.search('titleOfClass').text
  @cusip = info_table.search('cusip').text
  @value_in_thousands = to_integer(info_table.search('value').text)
  @shares_or_principal_amount_type = info_table.search('sshPrnamtType').text
  @shares_or_principal_amount = to_integer(info_table.search('sshPrnamt').text)

  not_found = info_table.search('putCall').count == 0
  @put_or_call = info_table.search('putCall').text unless not_found

  @investment_discretion = info_table.search('investmentDiscretion').text
  @other_managers = info_table.search('otherManager').text
  @voting_authority = {
    sole: to_integer(info_table.search('Sole').text),
    shared: to_integer(info_table.search('Shared').text),
    none: to_integer(info_table.search('None').text)
  }
end

Private Instance Methods

to_integer(text) click to toggle source
# File lib/thirteen_f/position.rb, line 48
def to_integer(text)
  text.delete(',').to_i
end