class Authkeys::KeyCollection

Public Class Methods

new(file) click to toggle source
# File lib/authkeys/key_collection.rb, line 3
def initialize(file)
  @file = file
end

Public Instance Methods

each() { |key| ... } click to toggle source
# File lib/authkeys/key_collection.rb, line 7
def each(&block)
  keys.each do |key|
    yield(key)
  end
end

Private Instance Methods

file_data() click to toggle source
# File lib/authkeys/key_collection.rb, line 29
def file_data
  @file_data ||= File.read(@file)
end
key_lines() click to toggle source
# File lib/authkeys/key_collection.rb, line 21
def key_lines
  raw_lines.reject {|item| item.strip.empty? || item.strip.start_with?("#") }
end
keys() click to toggle source
# File lib/authkeys/key_collection.rb, line 15
def keys
  key_lines.collect do |line|
    Key.new(line)
  end
end
raw_lines() click to toggle source
# File lib/authkeys/key_collection.rb, line 25
def raw_lines
  file_data.split("\n")
end