Class: MinitestToRspec::Model::HashExp
- Defined in:
- lib/minitest_to_rspec/model/hash_exp.rb
Overview
Data object. Represents a ‘:hash` S-expression.
Instance Method Summary collapse
-
#initialize(sexp) ⇒ HashExp
constructor
A new instance of HashExp.
-
#to_h ⇒ Object
A slightly nicer implementation would be: ‘@exp.each_slice(2).to_h` but that would require ruby >= 2.1.
Methods included from SexpAssertions
#assert_sexp_type, #assert_sexp_type_array, #sexp_type?
Constructor Details
#initialize(sexp) ⇒ HashExp
Returns a new instance of HashExp.
7 8 9 10 |
# File 'lib/minitest_to_rspec/model/hash_exp.rb', line 7 def initialize(sexp) assert_sexp_type(:hash, sexp) @exp = sexp.dup end |
Instance Method Details
#to_h ⇒ Object
A slightly nicer implementation would be: ‘@exp.each_slice(2).to_h` but that would require ruby >= 2.1
15 16 17 |
# File 'lib/minitest_to_rspec/model/hash_exp.rb', line 15 def to_h Hash[@exp[1..-1].each_slice(2).to_a] end |