Class: Shard::Gist
- Inherits:
-
Object
- Object
- Shard::Gist
- Defined in:
- lib/shard/gist.rb
Constant Summary collapse
- SHARD_FILENAME =
# Declarations #
#
/(?:^(\w+)\.)?shard\.rb$/
Instance Method Summary collapse
-
#all_files ⇒ Object
# Instance Methods # #.
- #description ⇒ Object
- #id ⇒ Object
-
#initialize(gist_hash) ⇒ Gist
constructor
# Constructor # #.
- #name ⇒ Object
- #ruby_files ⇒ Object
- #shard_file ⇒ Object
- #url ⇒ Object
- #username ⇒ Object
- #valid_shard? ⇒ Boolean
Constructor Details
#initialize(gist_hash) ⇒ Gist
# Constructor #
#
21 22 23 |
# File 'lib/shard/gist.rb', line 21 def initialize(gist_hash) @gist_hash = gist_hash end |
Instance Method Details
#all_files ⇒ Object
# Instance Methods #
#
31 32 33 |
# File 'lib/shard/gist.rb', line 31 def all_files files.values end |
#description ⇒ Object
35 36 37 |
# File 'lib/shard/gist.rb', line 35 def description @gist_hash.description end |
#id ⇒ Object
39 40 41 |
# File 'lib/shard/gist.rb', line 39 def id @gist_hash.id end |
#name ⇒ Object
43 44 45 46 47 |
# File 'lib/shard/gist.rb', line 43 def name match = shard_file.filename.match(SHARD_FILENAME) match[1] || id end |
#ruby_files ⇒ Object
49 50 51 |
# File 'lib/shard/gist.rb', line 49 def ruby_files files.select { |filename| filename =~ /\.rb$/ }.values end |
#shard_file ⇒ Object
53 54 55 |
# File 'lib/shard/gist.rb', line 53 def shard_file files.select { |filename| filename =~ SHARD_FILENAME }.values.first end |
#url ⇒ Object
57 58 59 |
# File 'lib/shard/gist.rb', line 57 def url @gist_hash.html_url end |
#username ⇒ Object
61 62 63 |
# File 'lib/shard/gist.rb', line 61 def username @gist_hash.user.login end |
#valid_shard? ⇒ Boolean
65 66 67 |
# File 'lib/shard/gist.rb', line 65 def valid_shard? ! shard_file.nil? end |