Class: Gitloggl::Toggle::Cli
- Inherits:
-
Object
- Object
- Gitloggl::Toggle::Cli
- Includes:
- Hooks, Hooks::InstanceHooks
- Defined in:
- lib/gitloggl/toggle/cli.rb
Instance Attribute Summary collapse
-
#date_from ⇒ Object
Returns the value of attribute date_from.
-
#date_to ⇒ Object
Returns the value of attribute date_to.
-
#token ⇒ Object
Returns the value of attribute token.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#workspace_id ⇒ Object
Returns the value of attribute workspace_id.
Instance Method Summary collapse
-
#initialize(params = {}) {|_self| ... } ⇒ Cli
constructor
A new instance of Cli.
- #run(page: 1) ⇒ Object
Constructor Details
#initialize(params = {}) {|_self| ... } ⇒ Cli
Returns a new instance of Cli.
12 13 14 15 |
# File 'lib/gitloggl/toggle/cli.rb', line 12 def initialize(params = {}) params.each { |k, v| public_send("#{k}=", v) } yield(self) if block_given? end |
Instance Attribute Details
#date_from ⇒ Object
Returns the value of attribute date_from.
10 11 12 |
# File 'lib/gitloggl/toggle/cli.rb', line 10 def date_from @date_from end |
#date_to ⇒ Object
Returns the value of attribute date_to.
10 11 12 |
# File 'lib/gitloggl/toggle/cli.rb', line 10 def date_to @date_to end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/gitloggl/toggle/cli.rb', line 10 def token @token end |
#verbose ⇒ Object
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/gitloggl/toggle/cli.rb', line 10 def verbose @verbose end |
#workspace_id ⇒ Object
Returns the value of attribute workspace_id.
10 11 12 |
# File 'lib/gitloggl/toggle/cli.rb', line 10 def workspace_id @workspace_id end |
Instance Method Details
#run(page: 1) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gitloggl/toggle/cli.rb', line 17 def run(page: 1) body = request(page) total_count = body.fetch('total_count') per_page = body.fetch('per_page') total_pages = total_count.fdiv(per_page).ceil result = OpenStruct.new( total_count: total_count, per_page: per_page, total_pages: total_pages, page: page, body: body ) run_hook(:on_first_page, result) if page == 1 run_hook(:on_each_page, result) run(page: page.next) if body['data'].length >= per_page end |