module LiteXBRL::Utils

Constants

CONSOLIDATED
NON_CONSOLIDATED
SECURITIES_CODE

Public Instance Methods

hash_with_default(default, hash) click to toggle source
# File lib/litexbrl/utils.rb, line 8
def hash_with_default(default, hash)
  hash.default = default
  hash
end
percent_to_f(val) click to toggle source
# File lib/litexbrl/utils.rb, line 69
def percent_to_f(val)
  (to_f(val) / 100).round(3) if present? val
end
present?(val) click to toggle source
# File lib/litexbrl/utils.rb, line 73
def present?(val)
  !!(val && val != "")
end
to_consolidation(consolidation) click to toggle source

連結・非連結を取得します

# 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) click to toggle source
# File lib/litexbrl/utils.rb, line 65
def to_f(val)
  val.delete(',').to_f if present? val
end
to_i(val) click to toggle source
# File lib/litexbrl/utils.rb, line 61
def to_i(val)
  val.delete(',').to_i if present? val
end
to_mill(val) click to toggle source

単位を100万円にします

# File lib/litexbrl/utils.rb, line 57
def to_mill(val)
  val.to_i / (1000 * 1000) if present? val
end
to_month(elm_end) click to toggle source

決算月を取得します

# 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) click to toggle source

証券コードを取得します

# 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) click to toggle source

決算年を取得します

# 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