Sha256: cf2ee6c39372e59a55bf05e739b27ae4937ed80bfa89b159d77cd33197662dbb
Contents?: true
Size: 947 Bytes
Versions: 3
Compression:
Stored size: 947 Bytes
Contents
module HackTree module Tools # compute_name_align(["alfa", "bravo"], 8..16) # => 8 def self.compute_name_align(names, limit) (v = eval(vn = "names")).is_a?(klass = Array) or raise ArgumentError, "`#{vn}` must be #{klass}, #{v.class} (#{v.inspect}) given" (v = eval(vn = "limit")).is_a?(klass = Range) or raise ArgumentError, "`#{vn}` must be #{klass}, #{v.class} (#{v.inspect}) given" computed = names.map(&:size).select {|n| n <= limit.max}.max.to_i [limit.min, computed].max end # format_node_name(node) # => "hello" # format_node_name(node, "yo") # => "yo" def self.format_node_name(node, name = nil) case node when Node::Group ::HackTree.conf.group_format when Node::Hack ::HackTree.conf.hack_format else raise ArgumentError, "Unknown node class #{node.class}, SE" end % (name || node.name).to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hack_tree-0.1.2 | lib/hack_tree/tools.rb |
hack_tree-0.1.1 | lib/hack_tree/tools.rb |
hack_tree-0.1.0 | lib/hack_tree/tools.rb |