Class: SecQuery::Transaction
- Inherits:
-
Object
- Object
- SecQuery::Transaction
- Defined in:
- lib/sec_query/transaction.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#date ⇒ Object
Returns the value of attribute date.
-
#deemed ⇒ Object
Returns the value of attribute deemed.
-
#derivative ⇒ Object
Returns the value of attribute derivative.
-
#exercise ⇒ Object
Returns the value of attribute exercise.
-
#exercised ⇒ Object
Returns the value of attribute exercised.
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#filing_number ⇒ Object
Returns the value of attribute filing_number.
-
#form ⇒ Object
Returns the value of attribute form.
-
#modes ⇒ Object
Returns the value of attribute modes.
-
#nature ⇒ Object
Returns the value of attribute nature.
-
#number ⇒ Object
Returns the value of attribute number.
-
#owned ⇒ Object
Returns the value of attribute owned.
-
#owner_cik ⇒ Object
Returns the value of attribute owner_cik.
-
#price ⇒ Object
Returns the value of attribute price.
-
#reporting_owner ⇒ Object
Returns the value of attribute reporting_owner.
-
#security_name ⇒ Object
Returns the value of attribute security_name.
-
#shares ⇒ Object
Returns the value of attribute shares.
-
#type ⇒ Object
Returns the value of attribute type.
-
#underlying_1 ⇒ Object
Returns the value of attribute underlying_1.
-
#underlying_2 ⇒ Object
Returns the value of attribute underlying_2.
-
#underlying_3 ⇒ Object
Returns the value of attribute underlying_3.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(transaction) ⇒ Transaction
constructor
A new instance of Transaction.
Constructor Details
#initialize(transaction) ⇒ Transaction
Returns a new instance of Transaction.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sec_query/transaction.rb', line 6 def initialize(transaction) @filing_number = transaction[:form].split("/")[-2][0..19] @code = transaction[:code] if transaction[:date] != nil and transaction[:date] != "-" date = transaction[:date].split("-") @date = Time.utc(date[0],date[1],date[2]) end @reporting_owner = transaction[:reporting_owner] @form = transaction[:form] @type = transaction[:type] @modes = transaction[:modes] @shares = transaction[:shares].to_f @price = transaction[:price].gsub("$", "").to_f @owned = transaction[:owned].to_f @number = transaction[:number].to_i @owner_cik = transaction[:owner_cik] @security_name = transaction[:security_name] @deemed = transaction[:deemed] @exercise = transaction[:exercise] @nature = transaction[:nature] @derivative = transaction[:derivative] @underlying_1 = transaction[:underlying_1].to_f @exercised = transaction[:exercised] @underlying_2 = transaction[:underlying_2].to_f if transaction[:expires] != nil; expires = transaction[:expires].split("-") @expires = Time.utc(expires[0],expires[1],expires[2].to_i) end @underlying_3 = transaction[:underlying_3].to_f end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def code @code end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def date @date end |
#deemed ⇒ Object
Returns the value of attribute deemed.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def deemed @deemed end |
#derivative ⇒ Object
Returns the value of attribute derivative.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def derivative @derivative end |
#exercise ⇒ Object
Returns the value of attribute exercise.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def exercise @exercise end |
#exercised ⇒ Object
Returns the value of attribute exercised.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def exercised @exercised end |
#expires ⇒ Object
Returns the value of attribute expires.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def expires @expires end |
#filing_number ⇒ Object
Returns the value of attribute filing_number.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def filing_number @filing_number end |
#form ⇒ Object
Returns the value of attribute form.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def form @form end |
#modes ⇒ Object
Returns the value of attribute modes.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def modes @modes end |
#nature ⇒ Object
Returns the value of attribute nature.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def nature @nature end |
#number ⇒ Object
Returns the value of attribute number.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def number @number end |
#owned ⇒ Object
Returns the value of attribute owned.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def owned @owned end |
#owner_cik ⇒ Object
Returns the value of attribute owner_cik.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def owner_cik @owner_cik end |
#price ⇒ Object
Returns the value of attribute price.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def price @price end |
#reporting_owner ⇒ Object
Returns the value of attribute reporting_owner.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def reporting_owner @reporting_owner end |
#security_name ⇒ Object
Returns the value of attribute security_name.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def security_name @security_name end |
#shares ⇒ Object
Returns the value of attribute shares.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def shares @shares end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def type @type end |
#underlying_1 ⇒ Object
Returns the value of attribute underlying_1.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def @underlying_1 end |
#underlying_2 ⇒ Object
Returns the value of attribute underlying_2.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def @underlying_2 end |
#underlying_3 ⇒ Object
Returns the value of attribute underlying_3.
4 5 6 |
# File 'lib/sec_query/transaction.rb', line 4 def @underlying_3 end |
Class Method Details
.find(entity, start, count, limit) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sec_query/transaction.rb', line 37 def self.find(entity, start, count, limit) if start == nil; start = 0; end if count == nil; count = 80; end url = "http://www.sec.gov/cgi-bin/own-disp?action=get"+entity[:type]+"&CIK="+entity[:cik]+"&start="+start.to_s+"&count="+count.to_s response = Entity.query(url) doc = Hpricot(response) trans = doc.search("//td[@width='40%']")[0].parent.parent.search("//tr") i= start; query_more = false; for tran in trans td = tran.search("//td") if td[2] != nil and td[1].innerHTML != "Exercise" query_more = true; if !td[0].empty? transaction={} transaction[:code] = td[0].innerHTML; transaction[:date] = td[1].innerHTML; transaction[:reporting_owner] = td[2].innerHTML; transaction[:form] = td[3].innerHTML; transaction[:type] = td[4].innerHTML; transaction[:modes] = td[5].innerHTML; transaction[:shares] = td[6].innerHTML; transaction[:price] = td[7].innerHTML; transaction[:owned] = td[8].innerHTML; transaction[:number] = td[9].innerHTML; transaction[:owner_cik] = td[10].innerHTML; transaction[:security_name] = td[11].innerHTML; transaction[:deemed] = td[12].innerHTML; if trans[i+1]; n_td = trans[i+1].search("//td"); end if n_td != nil and n_td.count ==7 and n_td[0].innerHTML.empty? transaction[:exercise] = n_td[1].innerHTML; transaction[:nature] = n_td[2].innerHTML; transaction[:derivative] = n_td[3].innerHTML; transaction[:underlying_1] = n_td[4].innerHTML; transaction[:exercised] = n_td[5].innerHTML; transaction[:underlying_2] = n_td[6].innerHTML; transaction[:expires] = n_td[7].innerHTML; transaction[:underlying_3] =n_td[8].innerHTML; end entity[:transactions] << Transaction.new(transaction) end end i=i+1 end if query_more and limit == nil || query_more and !limit Transaction.find(entity, start+count, count, limit); else return entity end end |