Class: Ace::Support::Nav::Models::HandbookSource

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/support/nav/models/handbook_source.rb

Overview

Represents a source of handbook resources

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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

#nameObject (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

#pathObject (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

#priorityObject (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_rootObject (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

#typeObject (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

Returns:

  • (Boolean)


32
33
34
# File 'lib/ace/support/nav/models/handbook_source.rb', line 32

def custom?
  type == :custom
end

#exists?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/ace/support/nav/models/handbook_source.rb', line 40

def exists?
  Dir.exist?(handbook_path)
end

#gem?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ace/support/nav/models/handbook_source.rb', line 28

def gem?
  type == :gem
end

#handbook_pathObject



36
37
38
# File 'lib/ace/support/nav/models/handbook_source.rb', line 36

def handbook_path
  resource_root
end

#project?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ace/support/nav/models/handbook_source.rb', line 20

def project?
  type == :project
end

#to_hObject



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

Returns:

  • (Boolean)


24
25
26
# File 'lib/ace/support/nav/models/handbook_source.rb', line 24

def user?
  type == :user
end