module LCClasses

Constants

CLASS_HASH

Library of Congress Main Classes and Subclasses

Public Class Methods

find_all_by_code(code) click to toggle source

Find all main classes and subclass that match or start with a code or character.

# File lib/lcclasses.rb, line 414
def self.find_all_by_code(code)
  LCClasses.flat.select { |i| i[0] if i[0] =~ /^#{code}[A-Z]?[A-Z]?/ }
end
find_by_code(code) click to toggle source
# File lib/lcclasses.rb, line 399
def self.find_by_code(code)
  LCClasses.flat.detect { |i| i[0] == code.to_s }
end
find_main_class_by_code(code) click to toggle source

Find an main classe by code.

# File lib/lcclasses.rb, line 404
def self.find_main_class_by_code(code)
  LCClasses.main_classes.detect { |i| i[0] == code.to_s }
end
find_subclass_by_code(code) click to toggle source

Find a subclass by code.

# File lib/lcclasses.rb, line 409
def self.find_subclass_by_code(code)
  LCClasses.subclasses.detect { |i| i[0] == code.to_s }
end
flat() click to toggle source

All main classes and subclasses in a flat array.

# File lib/lcclasses.rb, line 395
def self.flat
  LCClasses::LCClass.flatten(LCClasses::CLASS_HASH)
end
main_classes() click to toggle source

An array of main LC Classes.

# File lib/lcclasses.rb, line 376
def self.main_classes
  CLASS_HASH.map do |k, v|
    LCClasses::LCClass[k, v[:name]]
  end.sort
end
nested() click to toggle source

A nested array of main classes and subclasses.

# File lib/lcclasses.rb, line 390
def self.nested
  LCClasses::LCClass.nest(LCClasses::CLASS_HASH)
end
subclasses() click to toggle source

An array of all LC Subclasses.

# File lib/lcclasses.rb, line 383
def self.subclasses
  self.main_classes.inject([]) do |result, main_class|
    result + main_class.subclasses
  end
end