Class: Ucode::Commands::LookupCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/commands/lookup.rb

Overview

ucode lookup — read-only lookups against the SQLite cache and the output JSON tree. Three subactions: block, script, char.

Takes a resolved version string; CLI callers resolve via VersionResolver.resolve once and thread it through. See Candidate 4 of the 2026-06-29 architecture review.

Instance Method Summary collapse

Instance Method Details

#lookup_block(version, codepoint:) ⇒ BlockResult

Parameters:

  • version (String)

    resolved UCD version

  • codepoint (Integer)

Returns:

  • (BlockResult)


26
27
28
29
# File 'lib/ucode/commands/lookup.rb', line 26

def lookup_block(version, codepoint:)
  with_db(version) { |db| db.lookup_block(codepoint) }
    .then { |block| BlockResult.new(codepoint: codepoint, block: block) }
end

#lookup_char(version, codepoint:, output_root:) ⇒ CharResult

Parameters:

  • version (String)

    resolved UCD version

  • codepoint (Integer)
  • output_root (String, Pathname)

Returns:

  • (CharResult)


43
44
45
46
47
# File 'lib/ucode/commands/lookup.rb', line 43

def lookup_char(version, codepoint:, output_root:)
  block_id = with_db(version) { |db| db.lookup_block(codepoint) }
  glyph = block_id ? glyph_path(output_root, block_id, codepoint) : nil
  CharResult.new(codepoint: codepoint, block_id: block_id, glyph_path: glyph)
end

#lookup_script(version, codepoint:) ⇒ ScriptResult

Parameters:

  • version (String)

    resolved UCD version

  • codepoint (Integer)

Returns:

  • (ScriptResult)


34
35
36
37
# File 'lib/ucode/commands/lookup.rb', line 34

def lookup_script(version, codepoint:)
  with_db(version) { |db| db.lookup_script(codepoint) }
    .then { |script| ScriptResult.new(codepoint: codepoint, script: script) }
end