Module: Zakuro::Tool::Stringifier
- Defined in:
- lib/zakuro/tool/stringifier.rb
Overview
Stringifier 文字列処理
Class Method Summary collapse
-
.to_h(obj:, class_prefix:, formatted: true) ⇒ Hash<String, Objcet>
対象インスタンスをハッシュ化する.
Class Method Details
.to_h(obj:, class_prefix:, formatted: true) ⇒ Hash<String, Objcet>
対象インスタンスをハッシュ化する
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zakuro/tool/stringifier.rb', line 25 def to_h(obj:, class_prefix:, formatted: true) hash = {} obj.instance_variables.each do |var| key = var.to_s.delete('@') hash[key] = value_to_hash( obj: obj.instance_variable_get(var), class_prefix: class_prefix, formatted: formatted ) end hash end |