Class: Mconnect::Generator
- Inherits:
-
Object
- Object
- Mconnect::Generator
- Defined in:
- lib/mconnect/generator.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#initialize(content, directory, endpoint) ⇒ Generator
constructor
A new instance of Generator.
- #save_csv ⇒ Object
Constructor Details
#initialize(content, directory, endpoint) ⇒ Generator
Returns a new instance of Generator.
6 7 8 9 10 |
# File 'lib/mconnect/generator.rb', line 6 def initialize content, directory, endpoint @content = content @directory = directory @endpoint = endpoint end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/mconnect/generator.rb', line 3 def content @content end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
4 5 6 |
# File 'lib/mconnect/generator.rb', line 4 def directory @directory end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/mconnect/generator.rb', line 4 def endpoint @endpoint end |
Instance Method Details
#save_csv ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mconnect/generator.rb', line 12 def save_csv decorator = Mconnect::Decorator.new @content case endpoint when "teachers" content = decorator.remove_columns ['custom', 'saml_name'] when "students" content = decorator.remove_columns ['sections'] when "standards" content = decorator.flatten_column 'standards' when "sections" content = decorator.sections_hash end CSV.open("#{@directory}/#{@endpoint}.csv", "w", write_headers: true, headers: @content.first.keys) do |csv| @content.each do |hash| csv << hash.values end end end |