Module: LiteXBRL::Utils
- Included in:
- TDnet::FinancialInformation, TDnet::FinancialInformation2
- Defined in:
- lib/litexbrl/utils.rb
Constant Summary collapse
- SECURITIES_CODE =
/([\d|0-9]{4})/
- CONSOLIDATED =
"Consolidated"
- NON_CONSOLIDATED =
"NonConsolidated"
Instance Method Summary collapse
- #hash_with_default(default, hash) ⇒ Object
- #percent_to_f(val) ⇒ Object
- #present?(val) ⇒ Boolean
-
#to_consolidation(consolidation) ⇒ Object
連結・非連結を取得します.
- #to_f(val) ⇒ Object
- #to_i(val) ⇒ Object
-
#to_mill(val) ⇒ Object
単位を100万円にします.
-
#to_month(elm_end) ⇒ Object
決算月を取得します.
-
#to_securities_code(elm_code) ⇒ Object
証券コードを取得します.
-
#to_year(elm_end) ⇒ Object
決算年を取得します.
Instance Method Details
#hash_with_default(default, hash) ⇒ Object
8 9 10 11 |
# File 'lib/litexbrl/utils.rb', line 8 def hash_with_default(default, hash) hash.default = default hash end |
#percent_to_f(val) ⇒ Object
69 70 71 |
# File 'lib/litexbrl/utils.rb', line 69 def percent_to_f(val) (to_f(val) / 100).round(3) if present? val end |
#present?(val) ⇒ Boolean
73 74 75 |
# File 'lib/litexbrl/utils.rb', line 73 def present?(val) !!(val && val != "") end |
#to_consolidation(consolidation) ⇒ Object
連結・非連結を取得します
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/litexbrl/utils.rb', line 43 def to_consolidation(consolidation) case consolidation when CONSOLIDATED 1 when NON_CONSOLIDATED 0 else raise StandardError.new("連結・非連結を取得できません。") end end |
#to_f(val) ⇒ Object
65 66 67 |
# File 'lib/litexbrl/utils.rb', line 65 def to_f(val) val.delete(',').to_f if present? val end |
#to_i(val) ⇒ Object
61 62 63 |
# File 'lib/litexbrl/utils.rb', line 61 def to_i(val) val.delete(',').to_i if present? val end |
#to_mill(val) ⇒ Object
単位を100万円にします
57 58 59 |
# File 'lib/litexbrl/utils.rb', line 57 def to_mill(val) val.to_i / (1000 * 1000) if present? val end |
#to_month(elm_end) ⇒ Object
決算月を取得します
34 35 36 37 38 |
# File 'lib/litexbrl/utils.rb', line 34 def to_month(elm_end) raise StandardError.new("決算月を取得できません。") unless elm_end elm_end.content.split('-')[1].to_i end |
#to_securities_code(elm_code) ⇒ Object
証券コードを取得します
16 17 18 19 20 |
# File 'lib/litexbrl/utils.rb', line 16 def to_securities_code(elm_code) raise StandardError.new("証券コードを取得できません。") unless elm_code SECURITIES_CODE =~ elm_code.content && $1.tr("0-9", "0-9") end |
#to_year(elm_end) ⇒ Object
決算年を取得します
25 26 27 28 29 |
# File 'lib/litexbrl/utils.rb', line 25 def to_year(elm_end) raise StandardError.new("決算年を取得できません。") unless elm_end elm_end.content.split('-')[0].to_i end |