Class: Tapioca::RepoIndex
- Inherits:
-
Object
- Object
- Tapioca::RepoIndex
- Extended by:
- T::Generic, T::Sig
- Defined in:
- lib/tapioca/repo_index.rb
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
: (Hash[String, Hash[untyped, untyped]] hash) -> RepoIndex.
-
.from_json(json) ⇒ Object
: (String json) -> RepoIndex.
Instance Method Summary collapse
-
#<<(gem_name) ⇒ Object
: (String gem_name) -> void.
-
#gems ⇒ Object
: -> T::Enumerable.
-
#has_gem?(gem_name) ⇒ Boolean
: (String gem_name) -> bool.
-
#initialize ⇒ RepoIndex
constructor
: -> void.
Methods included from T::Generic::TypeStoragePatch
#[], #has_attached_class!, #type_member, #type_template
Constructor Details
#initialize ⇒ RepoIndex
: -> void
26 27 28 |
# File 'lib/tapioca/repo_index.rb', line 26 def initialize @entries = Set.new #: Set[String] end |
Class Method Details
.from_hash(hash) ⇒ Object
: (Hash[String, Hash[untyped, untyped]] hash) -> RepoIndex
18 19 20 21 22 |
# File 'lib/tapioca/repo_index.rb', line 18 def from_hash(hash) hash.each_with_object(RepoIndex.new) do |(name, _), index| index << name end end |
.from_json(json) ⇒ Object
: (String json) -> RepoIndex
13 14 15 |
# File 'lib/tapioca/repo_index.rb', line 13 def from_json(json) RepoIndex.from_hash(JSON.parse(json)) end |
Instance Method Details
#<<(gem_name) ⇒ Object
: (String gem_name) -> void
31 32 33 |
# File 'lib/tapioca/repo_index.rb', line 31 def <<(gem_name) @entries.add(gem_name) end |
#gems ⇒ Object
: -> T::Enumerable
36 37 38 |
# File 'lib/tapioca/repo_index.rb', line 36 def gems @entries.sort end |
#has_gem?(gem_name) ⇒ Boolean
: (String gem_name) -> bool
41 42 43 |
# File 'lib/tapioca/repo_index.rb', line 41 def has_gem?(gem_name) @entries.include?(gem_name) end |