Skip to content

Commit

Permalink
JsonFinder get children is now passing it's test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Walworth committed Mar 17, 2013
1 parent 3972f32 commit c8cdee6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/json_finder.coffee
@@ -1,19 +1,24 @@
class JsonFinder

constructor: (json) ->
@json = json

recurse_children: (name, obj) ->
@json = JSON.parse json
descend: (name, obj) ->
if obj.name == name
return obj.childs
else
obj.childs.every (child) ->
this.recurse_children(name,child)
for i in [0..obj.childs.length - 1]
if typeof(obj.childs[i]) == "string"
break
result = this.descend(name, obj.childs[i])
if typeof(result) != 'undefined'
return result

get_attr: (name) ->
"not impleneted yet"

get_children: (name) ->
return this.recurse_children(name,@json)
return this.descend(name, @json)

root = exports ? window
root.JsonFinder = JsonFinder

0 comments on commit c8cdee6

Please sign in to comment.