Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Submission for tic-tac-toe #116

Open
wants to merge 20 commits into
base: answers
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions final/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format documentation
13 changes: 13 additions & 0 deletions final/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Instructions For Using The RadianDegreeConverter
------------------------------------------------

This converter will convert radians to decimal degrees or decimal degrees to radians. It can be run from the command line using the executable or added to your code with the require statement. Note that input validation is done to ensure the input is a float compatible number. If it is not, the conversion will be aborted and an error message will be returned.

To install the gem:
* gem install radian_degree_converter

To run from the command line:
* radian_degree_converter

To add to your code:
* require 'radian_degree_converter'
5 changes: 5 additions & 0 deletions final/Rakefile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new('spec')

task :default => :spec
28 changes: 28 additions & 0 deletions final/bin/radian_degree_converter
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby

require 'radian_degree_converter'

@converter = RadianDegreeConverter.new
puts "Select one of the following options:"
puts "\t1. To convert radians to decimal degrees"
puts "\t2. To convert decimal degrees to radians"
print "\nEnter 1 or 2: "

option = gets.chomp
if option == '1'
print "Enter radians value: "
r_value = gets
result = @converter.convert_radians_to_degrees(r_value)
if (!result.nil?)
puts "The decimal degrees equivalent is #{result}"
end
elsif option == '2'
print "Enter decimal degrees value: "
d_value = gets
result = @converter.convert_degrees_to_radians(d_value)
if (!result.nil?)
puts "The radians equivalent is #{result}"
end
else
puts "Invalid selection"
end
299 changes: 299 additions & 0 deletions final/doc/RadianDegreeConverter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class RadianDegreeConverter - RDoc Documentation</title>

<link href="./fonts.css" rel="stylesheet">
<link href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
var rdoc_rel_prefix = "./";
</script>

<script src="./js/jquery.js"></script>
<script src="./js/navigation.js"></script>
<script src="./js/search_index.js"></script>
<script src="./js/search.js"></script>
<script src="./js/searcher.js"></script>
<script src="./js/darkfish.js"></script>


<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>

<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>

<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>

<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>

</div>



<div id="class-metadata">

<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>


<p class="link">Object

</div>



<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>

<ul class="link-list" role="directory">

<li ><a href="#method-i-convert_degrees_to_radians">#convert_degrees_to_radians</a>

<li ><a href="#method-i-convert_radians_to_degrees">#convert_radians_to_degrees</a>

<li ><a href="#method-i-error_message">#error_message</a>

<li ><a href="#method-i-is_numeric-3F">#is_numeric?</a>

</ul>
</div>

</div>
</nav>

<main role="main" aria-labelledby="class-RadianDegreeConverter">
<h1 id="class-RadianDegreeConverter" class="class">
class RadianDegreeConverter
</h1>

<section class="description">

<p>This class converts radians to decimal degrees and decimal degrees to
radians. It will validate the method input to make sure it is float
compatible and return an error message if the input cannot be converted to
a float.</p>
<dl class="rdoc-list note-list"><dt>Author
<dd>
<p>Kevin LaFave</p>
</dd><dt>License
<dd>
<p>MIT</p>
</dd></dl>

</section>




<section id="5Buntitled-5D" class="documentation-section">









<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Instance Methods</h3>
</header>


<div id="method-i-convert_degrees_to_radians" class="method-detail ">

<div class="method-heading">
<span class="method-name">convert_degrees_to_radians</span><span
class="method-args">(input)</span>

<span class="method-click-advice">click to toggle source</span>

</div>


<div class="method-description">

<p>This method converts decimal degrees to its radians equivalent.</p>
<ul><li>
<p>input : The decimal degree value that needs to be converted to radians.</p>
</li></ul>




<div class="method-source-code" id="convert_degrees_to_radians-source">
<pre><span class="ruby-comment"># File lib/radian_degree_converter.rb, line 39</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">convert_degrees_to_radians</span> <span class="ruby-identifier">input</span>
<span class="ruby-keyword">if</span> <span class="ruby-identifier">is_numeric?</span> <span class="ruby-identifier">input</span>
<span class="ruby-ivar">@result</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">*</span> <span class="ruby-value">0.0174532925</span>
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">error_message</span>
<span class="ruby-ivar">@result</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>

</div>




</div>


<div id="method-i-convert_radians_to_degrees" class="method-detail ">

<div class="method-heading">
<span class="method-name">convert_radians_to_degrees</span><span
class="method-args">(input)</span>

<span class="method-click-advice">click to toggle source</span>

</div>


<div class="method-description">

<p>This method converts radians to its decimal degrees equivalent.</p>
<ul><li>
<p>input : The radian value that needs to be converted to decimal degrees.</p>
</li></ul>




<div class="method-source-code" id="convert_radians_to_degrees-source">
<pre><span class="ruby-comment"># File lib/radian_degree_converter.rb, line 28</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">convert_radians_to_degrees</span> <span class="ruby-identifier">input</span>
<span class="ruby-keyword">if</span> <span class="ruby-identifier">is_numeric?</span> <span class="ruby-identifier">input</span>
<span class="ruby-ivar">@result</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">*</span> <span class="ruby-value">57.2957795</span>
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">error_message</span>
<span class="ruby-ivar">@result</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>

</div>




</div>


<div id="method-i-error_message" class="method-detail ">

<div class="method-heading">
<span class="method-name">error_message</span><span
class="method-args">()</span>

<span class="method-click-advice">click to toggle source</span>

</div>


<div class="method-description">

<p>This method returns an error message when the convert method input was not
float compatible.</p>




<div class="method-source-code" id="error_message-source">
<pre><span class="ruby-comment"># File lib/radian_degree_converter.rb, line 22</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">error_message</span>
<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Invalid input. Must enter an integer or decimal number&quot;</span>
<span class="ruby-keyword">end</span></pre>
</div>

</div>




</div>


<div id="method-i-is_numeric-3F" class="method-detail ">

<div class="method-heading">
<span class="method-name">is_numeric?</span><span
class="method-args">(input)</span>

<span class="method-click-advice">click to toggle source</span>

</div>


<div class="method-description">

<p>This method validates the input to see if it is float compatible.</p>
<ul><li>
<p>input : The value that needs to be validated.</p>
</li></ul>




<div class="method-source-code" id="is_numeric-3F-source">
<pre><span class="ruby-comment"># File lib/radian_degree_converter.rb, line 11</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">is_numeric?</span> <span class="ruby-identifier">input</span>
<span class="ruby-keyword">begin</span>
<span class="ruby-constant">Float</span>(<span class="ruby-identifier">input</span>)
<span class="ruby-keyword">rescue</span>
<span class="ruby-keyword">false</span>
<span class="ruby-keyword">else</span>
<span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>

</div>




</div>


</section>

</section>
</main>


<footer id="validator-badges" role="contentinfo">
<p><a href="http://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

2 changes: 2 additions & 0 deletions final/doc/created.rid
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sat, 08 Mar 2014 20:11:31 -0800
lib/radian_degree_converter.rb Sat, 08 Mar 2014 20:11:08 -0800
Loading