Class: JekyllGithubSample::FileHelper
- Inherits:
-
Object
- Object
- JekyllGithubSample::FileHelper
- Defined in:
- lib/jekyll_github_sample/file_helper.rb
Constant Summary collapse
- GITHUB_RAW_URI =
'https://raw.githubusercontent.com/'
- GITHUB_URI =
'https://github.com/'
- WEB_URI_PART =
'blob'
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(path) ⇒ FileHelper
constructor
A new instance of FileHelper.
- #raw_uri ⇒ Object
- #user_uri ⇒ Object
- #web_uri ⇒ Object
Constructor Details
#initialize(path) ⇒ FileHelper
Returns a new instance of FileHelper.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 10 def initialize(path) @path = path parts = @path.split('/').delete_if { |e| e.empty? } if parts.include? WEB_URI_PART @user, @project_name, @blob, @commitish_or_branch = parts[0..3] @filename = File.join(parts[4..-1]) else @user, @project_name, @commitish_or_branch = parts[0..2] @filename = File.join(parts[3..-1]) end end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 8 def filename @filename end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
8 9 10 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 8 def project_name @project_name end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 8 def user @user end |
Instance Method Details
#raw_uri ⇒ Object
30 31 32 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 30 def raw_uri File.join(GITHUB_RAW_URI, @user, @project_name, @commitish_or_branch, @filename) end |
#user_uri ⇒ Object
22 23 24 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 22 def user_uri File.join(GITHUB_URI, @user) end |
#web_uri ⇒ Object
26 27 28 |
# File 'lib/jekyll_github_sample/file_helper.rb', line 26 def web_uri File.join(GITHUB_URI, @user, @project_name, WEB_URI_PART, @commitish_or_branch, @filename) end |