Class: Ace::Support::Nav::Models::HandbookSource
- Inherits:
-
Object
- Object
- Ace::Support::Nav::Models::HandbookSource
- Defined in:
- lib/ace/support/nav/models/handbook_source.rb
Overview
Represents a source of handbook resources
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#resource_root ⇒ Object
readonly
Returns the value of attribute resource_root.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #custom? ⇒ Boolean
- #exists? ⇒ Boolean
- #gem? ⇒ Boolean
- #handbook_path ⇒ Object
-
#initialize(name:, path:, alias_name: nil, type: :gem, priority: 100, resource_root: nil) ⇒ HandbookSource
constructor
A new instance of HandbookSource.
- #project? ⇒ Boolean
- #to_h ⇒ Object
- #user? ⇒ Boolean
Constructor Details
#initialize(name:, path:, alias_name: nil, type: :gem, priority: 100, resource_root: nil) ⇒ HandbookSource
Returns a new instance of HandbookSource.
11 12 13 14 15 16 17 18 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 11 def initialize(name:, path:, alias_name: nil, type: :gem, priority: 100, resource_root: nil) @name = name @path = path @alias_name = alias_name || derive_alias(name, type) @type = type # :project, :user, :gem, :custom @priority = priority @resource_root = resource_root || default_resource_root end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
9 10 11 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 9 def alias_name @alias_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 9 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 9 def path @path end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
9 10 11 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 9 def priority @priority end |
#resource_root ⇒ Object (readonly)
Returns the value of attribute resource_root.
9 10 11 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 9 def resource_root @resource_root end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 9 def type @type end |
Instance Method Details
#custom? ⇒ Boolean
32 33 34 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 32 def custom? type == :custom end |
#exists? ⇒ Boolean
40 41 42 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 40 def exists? Dir.exist?(handbook_path) end |
#gem? ⇒ Boolean
28 29 30 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 28 def gem? type == :gem end |
#handbook_path ⇒ Object
36 37 38 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 36 def handbook_path resource_root end |
#project? ⇒ Boolean
20 21 22 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 20 def project? type == :project end |
#to_h ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 44 def to_h { name: name, path: path, alias: alias_name, type: type, priority: priority, exists: exists? } end |
#user? ⇒ Boolean
24 25 26 |
# File 'lib/ace/support/nav/models/handbook_source.rb', line 24 def user? type == :user end |