Class: ThirteenF::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/thirteen_f/position.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filing: nil, time_accepted: nil) ⇒ Position

Returns a new instance of Position.



24
25
26
27
# File 'lib/thirteen_f/position.rb', line 24

def initialize(filing: nil, time_accepted: nil)
  @filing = filing
  @time_accepted = time_accepted
end

Instance Attribute Details

#cusipObject (readonly)

Returns the value of attribute cusip.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def cusip
  @cusip
end

#filingObject (readonly)

Returns the value of attribute filing.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def filing
  @filing
end

#investment_discretionObject (readonly)

Returns the value of attribute investment_discretion.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def investment_discretion
  @investment_discretion
end

#name_of_issuerObject (readonly)

Returns the value of attribute name_of_issuer.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def name_of_issuer
  @name_of_issuer
end

#other_managersObject (readonly)

Returns the value of attribute other_managers.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def other_managers
  @other_managers
end

#put_or_callObject (readonly)

Returns the value of attribute put_or_call.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def put_or_call
  @put_or_call
end

#shares_or_principal_amountObject (readonly)

Returns the value of attribute shares_or_principal_amount.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def shares_or_principal_amount
  @shares_or_principal_amount
end

#shares_or_principal_amount_typeObject (readonly)

Returns the value of attribute shares_or_principal_amount_type.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def shares_or_principal_amount_type
  @shares_or_principal_amount_type
end

#time_acceptedObject (readonly)

Returns the value of attribute time_accepted.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def time_accepted
  @time_accepted
end

#title_of_classObject (readonly)

Returns the value of attribute title_of_class.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def title_of_class
  @title_of_class
end

#value_in_thousandsObject (readonly)

Returns the value of attribute value_in_thousands.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def value_in_thousands
  @value_in_thousands
end

#voting_authorityObject (readonly)

Returns the value of attribute voting_authority.



5
6
7
# File 'lib/thirteen_f/position.rb', line 5

def voting_authority
  @voting_authority
end

Class Method Details

.from_xml_filing(filing) ⇒ Object



10
11
12
13
# File 'lib/thirteen_f/position.rb', line 10

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, time_accepted: nil) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/thirteen_f/position.rb', line 15

def self.from_xml_url(table_xml_url, filing: nil, time_accepted: nil)
  xml_doc = SecRequest.get table_xml_url, response_type: :xml
  xml_doc.search("//infoTable").map do |info_table|
    position = new filing: filing, time_accepted: time_accepted
    position.attributes_from_info_table(info_table)
    position
  end
end

Instance Method Details

#attributes_from_info_table(info_table) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/thirteen_f/position.rb', line 29

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 = set_value_to_thousands info_table.search('value').text
  @shares_or_principal_amount_type = info_table.search('sshPrnamtType').text
  @shares_or_principal_amount = to_float(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_float(info_table.search('Sole').text),
    shared: to_float(info_table.search('Shared').text),
    none: to_float(info_table.search('None').text)
  }
end