Class: Michael::Models::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/michael/models/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(org_name, prs: nil) ⇒ Repository

Returns a new instance of Repository.



10
11
12
13
# File 'lib/michael/models/repository.rb', line 10

def initialize(org_name, prs: nil)
  @org_name = org_name
  @prs = prs
end

Instance Attribute Details

#org_nameObject (readonly)

Returns the value of attribute org_name.



8
9
10
# File 'lib/michael/models/repository.rb', line 8

def org_name
  @org_name
end

#prsObject (readonly)

Returns the value of attribute prs.



8
9
10
# File 'lib/michael/models/repository.rb', line 8

def prs
  @prs
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
# File 'lib/michael/models/repository.rb', line 23

def ==(other)
  org_name == other.org_name &&
    prs == other.prs
end

#broken?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/michael/models/repository.rb', line 15

def broken?
  prs.nil?
end

#has_prs?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/michael/models/repository.rb', line 19

def has_prs?
  !broken? && prs.any?
end

#pretty_printObject



28
29
30
31
32
33
34
35
36
# File 'lib/michael/models/repository.rb', line 28

def pretty_print
  return pastel.black.on_red(org_name) if broken?
  return org_name if prs.none?

  [
    pastel.bold(org_name + ':'),
    prs.map(&:pretty_print).join("\n")
  ].join("\n")
end