module Base::ClassMethods
Public Instance Methods
all()
click to toggle source
# File lib/models/base.rb, line 15 def all load end
headers_raw()
click to toggle source
# File lib/models/base.rb, line 19 def headers_raw @headers end
load(lines = raw_lines)
click to toggle source
# File lib/models/base.rb, line 8 def load(lines = raw_lines) @headers = lines.first @items = lines[1..-1].map do |line| create(line) end end
print_table(data) { |item, index| ... }
click to toggle source
# File lib/models/base.rb, line 34 def print_table(data) hammer.say @headers ret = data.each_with_index.map do |item, index| item = yield(item, index) if block_given? item.to_s end.join('') hammer.say ret end
raw_lines()
click to toggle source
# File lib/models/base.rb, line 4 def raw_lines hammer.run(command, capture: true).lines end
run(*cmds)
click to toggle source
# File lib/models/base.rb, line 43 def run(*cmds) hammer.run(cmds.join(' ')) end
search(*keywords)
click to toggle source
# File lib/models/base.rb, line 23 def search(*keywords) keyword, = keywords keyword ||= '.' regexp = /#{keyword}/i ret = load.reject do |item| item.regexp = regexp regexp.match(item.raw).nil? end ret end