D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Data
/
Filename :
to_h-i.ri
back
Copy
U:RDoc::AnyMethod[iI" to_h:ETI"Data#to_h;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"4Returns Hash representation of the data object.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I"+Measure = Data.define(:amount, :unit) ;TI""distance = Measure[10, 'km'] ;TI" ;TI"distance.to_h ;TI"$#=> {:amount=>10, :unit=>"km"} ;T:@format0o; ; [I"GLike Enumerable#to_h, if the block is provided, it is expected to ;TI"1produce key-value pairs to construct a hash:;T@o;; [I"9distance.to_h { |name, val| [name.to_s, val.to_s] } ;TI"(#=> {"amount"=>"10", "unit"=>"km"} ;T; 0o; ; [I"HNote that there is a useful symmetry between #to_h and #initialize:;T@o;; [ I".distance2 = Measure.new(**distance.to_h) ;TI".#=> #<data Measure amount=10, unit="km"> ;TI"distance2 == distance ;TI" #=> true;T; 0: @fileI" struct.c;T:0@omit_headings_from_table_of_contents_below0I"4to_h -> hash to_h {|name, value| ... } -> hash ;T0[ I"();T@'FI" Data;TcRDoc::NormalClass00