Class: Github::File

Inherits:
Object
  • Object
show all
Includes:
Checks
Defined in:
app/github/file.rb

Overview

A GitHub file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Checks

#check_boolean, #check_enumerable_of, #check_is_a, #check_non_empty_string, #check_non_nil, #check_positive_integer

Constructor Details

#initialize(owner:, repo:, ref:, tree_sha:, path:, content:) ⇒ File

Returns a new instance of File.



12
13
14
15
16
17
18
19
# File 'app/github/file.rb', line 12

def initialize(owner:, repo:, ref:, tree_sha:, path:, content:)
  check_non_empty_string(owner: owner, repo: repo, ref: ref, path: path, tree_sha: tree_sha)
  @full_path = "#{owner}/#{repo}/#{ref}/#{path}"
  @path = path
  @tree_sha = tree_sha
  @content = check_is_a(content: [String, content])
  @github_url = "https://github.com/#{owner}/#{repo}/blob/#{ref}/#{path}"
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



10
11
12
# File 'app/github/file.rb', line 10

def content
  @content
end

#full_pathObject (readonly)

Returns the value of attribute full_path.



10
11
12
# File 'app/github/file.rb', line 10

def full_path
  @full_path
end

#github_urlObject (readonly)

Returns the value of attribute github_url.



10
11
12
# File 'app/github/file.rb', line 10

def github_url
  @github_url
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'app/github/file.rb', line 10

def path
  @path
end

#tree_shaObject (readonly)

Returns the value of attribute tree_sha.



10
11
12
# File 'app/github/file.rb', line 10

def tree_sha
  @tree_sha
end

Instance Method Details

#==(other) ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/github/file.rb', line 21

def ==(other)
  self.class == other.class &&
    @full_path == other.full_path &&
    @path == other.path &&
    @tree_sha == other.tree_sha &&
    @content == other.content &&
    @github_url == other.github_url
end