Class: EnvPullRequest::Base
- Inherits:
-
Object
- Object
- EnvPullRequest::Base
- Includes:
- NaturalNumberString
- Defined in:
- lib/env_pull_request/base.rb
Instance Attribute Summary collapse
-
#pull_request_id ⇒ Object
readonly
Returns the value of attribute pull_request_id.
Instance Method Summary collapse
- #fetch_pull_request_id ⇒ Object
-
#initialize(&block) ⇒ Base
constructor
A new instance of Base.
- #pull_request? ⇒ Boolean
Constructor Details
#initialize(&block) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 |
# File 'lib/env_pull_request/base.rb', line 6 def initialize(&block) @pull_request_id = if block_given? block.call || fetch_pull_request_id else fetch_pull_request_id end end |
Instance Attribute Details
#pull_request_id ⇒ Object (readonly)
Returns the value of attribute pull_request_id.
4 5 6 |
# File 'lib/env_pull_request/base.rb', line 4 def pull_request_id @pull_request_id end |
Instance Method Details
#fetch_pull_request_id ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/env_pull_request/base.rb', line 15 def fetch_pull_request_id if positive_integer_string? ENV['TRAVIS_PULL_REQUEST'] ENV['TRAVIS_PULL_REQUEST'].to_i elsif positive_integer_string? ENV['CIRCLE_PR_NUMBER'] ENV['CIRCLE_PR_NUMBER'].to_i elsif positive_integer_string? ENV['ghprbPullId'] ENV['ghprbPullId'].to_i end end |
#pull_request? ⇒ Boolean
25 26 27 |
# File 'lib/env_pull_request/base.rb', line 25 def pull_request? !pull_request_id.nil? end |