This repository was archived by the owner on Dec 1, 2021. It is now read-only.
  
  
  - 
                Notifications
    You must be signed in to change notification settings 
- Fork 29
DougM tic-tac-toe submission for final #118
          
     Open
      
      
            Doug-MacDowell
  wants to merge
  21
  commits into
  UWE-Ruby:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
Doug-MacDowell:master
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 17 commits
      Commits
    
    
            Show all changes
          
          
            21 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      a3d3aba
              
                Added info for number 17
              
              
                Doug-MacDowell eb43242
              
                Homework submission
              
              
                Doug-MacDowell 66ca065
              
                temp file
              
              
                Doug-MacDowell 3cea7d1
              
                a comment
              
              
                Doug-MacDowell 62b40ca
              
                week 2 material
              
              
                Doug-MacDowell 7cfc148
              
                Homework complete for week 2
              
              
                Doug-MacDowell f6936f6
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell 85f56ea
              
                Week 3 homework submission
              
              
                Doug-MacDowell cb7524a
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell 8b55bb6
              
                Week 4 homework answers from Doug M
              
              
                Doug-MacDowell b6e457e
              
                Week 4 worker file submission for spec
              
              
                Doug-MacDowell 36e367a
              
                This file appears to have not been committed in Week 2
              
              
                Doug-MacDowell 6198eb0
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell 2d476c0
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell b31602e
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell 267f1e1
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell 262f033
              
                DougM homework for week 7
              
              
                Doug-MacDowell 837425f
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell 21113f2
              
                Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
              
              
                Doug-MacDowell fce2aef
              
                Initial commit
              
              
                Doug-MacDowell e214aa6
              
                renamed the file to match others in project
              
              
                Doug-MacDowell File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| module SimonSays | ||
|  | ||
| attr_reader :the_string | ||
|  | ||
| def initialize | ||
| @the_string = the_string | ||
| end | ||
|  | ||
| def echo the_string | ||
| the_string | ||
| end | ||
|  | ||
| def shout(the_string) | ||
| the_string.upcase | ||
| end | ||
|  | ||
| def repeat(the_string, the_count=2) | ||
| a = Array.new(the_count, the_string) | ||
| a.join ' ' | ||
| end | ||
|  | ||
| def start_of_word(the_string, n) | ||
| letters = n - 1 | ||
| the_string.slice(0..letters) | ||
| end | ||
|  | ||
| def first_word(the_string) | ||
| the_string.split[0..0].join(' ') | ||
| end | ||
|  | ||
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| class Calculator | ||
|  | ||
| def pow(val1, val2) | ||
| val1**val2 | ||
| end | ||
|  | ||
| def sum(the_input) | ||
| the_sum = 0 | ||
| the_input.each do |value| | ||
| the_sum += value | ||
| end | ||
| return the_sum | ||
| end | ||
|  | ||
| def fac(x) | ||
| (1..(x.zero? ? 1 : x)).inject(:*) | ||
| end | ||
|  | ||
| # the version below works for multiple values and arrays | ||
| def multiply(*input) | ||
| input.flatten.inject(:*) | ||
| end | ||
|  | ||
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| class Worker | ||
|  | ||
| # this only works for one block execution | ||
| # | ||
| # def self.work | ||
| # yield | ||
| # end | ||
| # | ||
| # this works for all blocks in this exercise | ||
| # | ||
| def self.work(count = 1) | ||
| (0..count).inject {yield} | ||
| end | ||
|  | ||
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| class PirateTranslator | ||
|  | ||
| def initialize | ||
| @reply = "Ahoy Matey\n Shiber Me Timbers You Scurvey Dogs!!" | ||
| end | ||
|  | ||
| def send(*arg) | ||
| @result = @reply | ||
| end | ||
|  | ||
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -3,7 +3,16 @@ Please Read Chapters 23 and 24 DuckTyping and MetaProgramming | |
|  | ||
| Questions: | ||
| 1. What is method_missing and how can it be used? | ||
| A. This is a hook method that Ruby will try to invoke on an object when a method call is made and Ruby can't find the method in the object's class or superclasses. It can be used to intercept and handle (or report) undefined methods, or it can be used with patterns to selectively forward particular method calls to a superclass. | ||
|  | ||
| 2. What is and Eigenclass and what is it used for? Where Do Singleton methods live? | ||
| A. An Eigenclass is a dynamically created anonymous class that holds an object's singleton methods. It is used when you need Ruby to find the object's singleton methods without disrupting the method lookup path. Singleton methods are defined on the objects themselves, rather than in its class, therefore they are dynamic. | ||
|  | ||
| 3. When would you use DuckTypeing? How would you use it to improve your code? | ||
| A. Duck Typing is a useful technique in situations where you want flexibility, without having to check the type of the arguments, which generally doesn't add any value. Code is improved and more flexible when you don't have to include checks on the argument types. | ||
|  | ||
| 4. What is the difference between a class method and an instance method? What is the difference between instance_eval and class_eval? | ||
| A. A class method is defined within a class and the method can be used in any subclasses of that class. Instance methods are created in a module and are available as instance methods of the class that includes the module. class_eval sets things up as if you were within a class definition. Any method definitions created there define instance methods. Calling instance_eval on a class differs because method definitions created there are class methods. | ||
|  | ||
| 5. What is the difference between a singleton class and a singleton method? | ||
| A. A singleton method is a method that is specific to a particular object, while a singleton class is an anonymous class that Ruby creates when defining a singleton method. | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent. | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good.