Class: Rubydex::Skill
- Inherits:
-
Object
- Object
- Rubydex::Skill
- Defined in:
- lib/rubydex/skill.rb
Overview
A skill file loaded from disk. Skill files are Markdown documents with YAML frontmatter
that declare a name and description. The body is the Markdown content after the frontmatter.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
: String.
-
#description ⇒ Object
readonly
: String.
-
#name ⇒ Object
readonly
: String.
Class Method Summary collapse
-
.from_content(content, path: nil) ⇒ Object
: (String content, ?path: String?) -> Rubydex::Skill.
-
.load(path) ⇒ Object
: (String path) -> Rubydex::Skill.
Instance Method Summary collapse
-
#initialize(name:, description:, body:) ⇒ Skill
constructor
: (name: String, description: String, body: String) -> void.
Constructor Details
#initialize(name:, description:, body:) ⇒ Skill
: (name: String, description: String, body: String) -> void
82 83 84 85 86 87 |
# File 'lib/rubydex/skill.rb', line 82 def initialize(name:, description:, body:) @name = name.freeze @description = description.freeze @body = body.freeze freeze end |
Instance Attribute Details
#body ⇒ Object (readonly)
: String
17 18 19 |
# File 'lib/rubydex/skill.rb', line 17 def body @body end |
#description ⇒ Object (readonly)
: String
14 15 16 |
# File 'lib/rubydex/skill.rb', line 14 def description @description end |
#name ⇒ Object (readonly)
: String
11 12 13 |
# File 'lib/rubydex/skill.rb', line 11 def name @name end |
Class Method Details
.from_content(content, path: nil) ⇒ Object
: (String content, ?path: String?) -> Rubydex::Skill
28 29 30 |
# File 'lib/rubydex/skill.rb', line 28 def from_content(content, path: nil) new(**parse(content, path:)) end |
.load(path) ⇒ Object
: (String path) -> Rubydex::Skill
21 22 23 24 25 |
# File 'lib/rubydex/skill.rb', line 21 def load(path) from_content(File.read(path), path:) rescue SystemCallError, IOError => e raise SkillError, "Cannot read skill file #{path}: #{e.message}" end |