module Minireq::Core::Excerpt
Constants
- EXCERPT_REGX
- LEXCERPT
- REXCERPT
Public Instance Methods
excerpt_to_hash(text)
click to toggle source
# File lib/minireq/core/excerpt.rb, line 21 def excerpt_to_hash(text) h = {} text.each_line do |line| line.strip! line.scrub! next if line.empty? next if line.start_with?(LEXCERPT) || line.start_with?(REXCERPT) pair = EXCERPT_REGX.match(line) key = pair[1] val = pair[2] h[key.to_sym] = val end h end
hash_to_excerpt(hash)
click to toggle source
# File lib/minireq/core/excerpt.rb, line 13 def hash_to_excerpt(hash) s = '' s << LEXCERPT + "\n" hash.each_pair { |k, v| s << "#{k}: #{v}\n" } s << REXCERPT + "\n" s end