Sha256: 34f0fe9d2e0fd0f9f5ea9600b1d4cf64a1f0bf9d5aa7a270341330200defb501

Contents?: true

Size: 759 Bytes

Versions: 5

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

module WB
  class Note
    attr_reader :path, :number

    def self.all
      WB.config.notes
    end

    def self.find_by_number(number)
      all.find { |note| note.number == number }
    end

    def self.find_by_full_path(full_path)
      all.find { |note| note.path == full_path }
    end

    def self.find_by_basename(basename)
      all.find { |note| File.basename(note.path) == basename }
    end

    def self.find_note(name)
      find_by_full_path(name) || find_by_basename(name)
    end

    def self.list_notes
      all.each { |note| $stdout.puts note }
    end

    def initialize(path, number)
      @path = path
      @number = number.to_s
    end

    def to_s
      %Q(#{number}: #{path})
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wb-1.1.0 lib/wb/note.rb
wb-1.0.3 lib/wb/note.rb
wb-1.0.2 lib/wb/note.rb
wb-1.0.1 lib/wb/note.rb
wb-1.0.0 lib/wb/note.rb