module VV::ArrayMethods
Public Class Methods
included(base)
click to toggle source
# File lib/vv/array_methods.rb, line 4 def self.included(base) base.extend(ClassMethods) base.include(VV::SetMethods::SetAndArrayMethods) base.attr_accessor :cli_print_separator end
Public Instance Methods
cli_print(width: nil, padding: nil, position: nil, separator: nil)
click to toggle source
# File lib/vv/array_methods.rb, line 66 def cli_print width: nil, padding: nil, position: nil, separator: nil width ||= 80 padding ||= 0 position ||= 0 @cli_print_separator ||= String.space separator ||= @cli_print_separator pad_length = padding - position position += pad_length print pad_length.spaces separator_required = false self.each do | elem | printable = String.capture_stdout { elem.cli_print width: width, padding: padding, position: position } string = printable.dup string.prepend separator if separator_required delta = string.unstyled.length if position + delta > width puts print padding.spaces print printable position = padding + printable.unstyled.length else print string position += delta end separator_required = true end position end
eighth()
click to toggle source
# File lib/vv/array_methods.rb, line 54 def eighth self[7] end
fifth()
click to toggle source
# File lib/vv/array_methods.rb, line 42 def fifth self[4] end
format!(other)
click to toggle source
# File lib/vv/array_methods.rb, line 26 def format!(other) self.spaced.format! other end
fourth()
click to toggle source
# File lib/vv/array_methods.rb, line 38 def fourth self[3] end
ninth()
click to toggle source
# File lib/vv/array_methods.rb, line 58 def ninth self[8] end
second()
click to toggle source
# File lib/vv/array_methods.rb, line 30 def second self[1] end
seventh()
click to toggle source
# File lib/vv/array_methods.rb, line 50 def seventh self[6] end
sixth()
click to toggle source
# File lib/vv/array_methods.rb, line 46 def sixth self[5] end
spaced()
click to toggle source
# File lib/vv/array_methods.rb, line 22 def spaced self.join(" ") end
tenth()
click to toggle source
# File lib/vv/array_methods.rb, line 62 def tenth self[9] end
third()
click to toggle source
# File lib/vv/array_methods.rb, line 34 def third self[2] end
vv_json()
click to toggle source
# File lib/vv/array_methods.rb, line 18 def vv_json VV::JSON.generate self end