Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/glyph/node.rb,
lib/glyph/system_extensions.rb

Overview

Core Hash class.

Direct Known Subclasses

Node

Instance Method Summary collapse

Instance Method Details

#to_nodeNode

Converts self to a Node

Returns:

  • (Node)

    the converted Node


8
9
10
# File 'lib/glyph/node.rb', line 8

def to_node
	Node.new.replace self
end

#to_options(sep = " ") ⇒ Object

Converts the hash to a string of Glyph options.


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/glyph/system_extensions.rb', line 20

def to_options(sep=" ")
	"".tap do |s|
		self.each_pair do |k, v|
			key = k.to_s
			s += key.length == 1 ? "-" : "--"
			s += key
			s += sep
			s += v.to_s =~ /\s/ ? "\"#{v}\"" : v.to_s
			s += " "
		end
	end.strip
end