todo.rb
# Takes the passed array of goals in string format and parse each
# element. A new goal object is then initialized from the parsed
# information.
#
Takes the passed array of goals in string format and parse each
element. A new goal object is then initialized from the parsed
information.
Takes the passed array of goals in string format and parse each element . A new goal object is then initialized from the parsed information .
def convert_to_goals(str_goals)
  id = 1
  for goal in str_goals
    goal_info = []
    goal_info = goal.split(/(\[ \])|(\[x\])/)
    status = $status_symbol.key(goal_info.at(1).strip)
    content = goal_info.at(2).strip
    $goals.push(Goal.new(id, status, content))
    if status == true
      $completed.push(id - 1)
    else
      $not_completed.push(id - 1)
    end
    id += 1
  end
end
def convert_to_goals ( str_goals ) id = 1 for goal in str_goals goal_info = [ ] goal_info = goal . split ( / ( \[ \] )|( \[ x \] ) / ) status = $status_symbol . key ( goal_info . at ( 1 ) . strip ) content = goal_info . at ( 2 ) . strip $goals . push ( Goal . new ( id , status , content ) ) if status == true $completed . push ( id - 1 ) else $not_completed . push ( id - 1 ) end id += 1 end end
Takes the passed array of goals in string format and parse each
element.
Takes the passed array of goals in string format and parse each element .
# split the information of the received string as # [0]<id> [1]<status> [2]<content>
str_goals