chore: Rename methods to improve code clarity

This commit is contained in:
Rekai Nyangadzayi Musuka 2020-09-07 17:32:23 -05:00
parent 81a02edc2b
commit d54aeaf005
2 changed files with 11 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target
/.vscode
/.idea

View File

@ -15,8 +15,8 @@ pub struct Pomodoro {
static POMODORO_CYCLES: u64 = 5;
static WORK_TIME: u64 = 1500; // Default: 1500 (25min)
static SBREAK_TIME: u64 = 300; // Default: 300 (5min)
static LBREAK_TIME: u64 = 600; // Default: 600 (10min)
static SHORT_BREAK_TIME: u64 = 300; // Default: 300 (5min)
static LONG_BREAK_TIME: u64 = 600; // Default: 600 (10min)
static POLLING_RATE: Duration = Duration::from_millis(300);
impl Pomodoro {
@ -57,7 +57,7 @@ impl Pomodoro {
}
fn notify(&self) -> Result<(), Box<dyn Error>> {
fn pmdr_cycle_count(i: u64) -> String {
fn cycle_count(i: u64) -> String {
let i = i / 4;
match i {
1 => "After this, you will have completed 1 cycle.".to_string(),
@ -65,7 +65,7 @@ impl Pomodoro {
}
}
fn work_sesh_num(i: u64) -> &'static str {
fn session_num(i: u64) -> &'static str {
match i % 4 {
0 => "Time for your 1st work session.",
1 => "Time for your 2nd work session.",
@ -81,7 +81,7 @@ impl Pomodoro {
State::Inactive => {}
State::Work => {
toast
.summary(work_sesh_num(self.count))
.summary(session_num(self.count))
.body("Remember to stay focused.")
.show()?;
}
@ -94,7 +94,7 @@ impl Pomodoro {
State::LongBreak => {
toast
.summary("Enjoy your long break!")
.body(&pmdr_cycle_count(self.count))
.body(&cycle_count(self.count))
.show()?;
}
};
@ -162,7 +162,7 @@ impl Pomodoro {
let mut handle = out.lock();
// Empty String so that we can clear line before writing
// from the mostleft side of the terminal again.
// from the most-left side of the terminal again.
handle.write_all(b"\r ")?;
handle.write_all(text.as_bytes())?;
handle.flush()?;
@ -213,8 +213,8 @@ impl Pomodoro {
fn wait_times(state: State) -> Duration {
match state {
State::Work => Duration::from_secs(WORK_TIME),
State::ShortBreak => Duration::from_secs(SBREAK_TIME),
State::LongBreak => Duration::from_secs(LBREAK_TIME),
State::ShortBreak => Duration::from_secs(SHORT_BREAK_TIME),
State::LongBreak => Duration::from_secs(LONG_BREAK_TIME),
_ => unreachable!("Can not have Pomodoro state = State::Inactive and wait_start = Some(...) at the same time.")
}
}