query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
This test is for the root alone without any children being linked
|
def test_root_setup
assert_not_nil(@root , "Root cannot be nil")
assert_nil(@root.parent , "Parent of root node should be nil")
assert_not_nil(@root.name , "Name should not be nil")
assert_equal("ROOT" , @root.name, "Name should be 'ROOT'")
assert_equal("Root Node" , @root.content, "Content should be 'Root Node'")
assert(@root.is_root? , "Should identify as root")
assert(!@root.has_children? , "Cannot have any children")
assert(@root.has_content? , "This root should have content")
assert_equal(1 , @root.size, "Number of nodes should be one")
assert_equal(0, @root.siblings.length, "This root does not have any children")
assert_equal(0, @root.in_degree, "Root should have an in-degree of 0")
assert_equal(0, @root.node_height, "Root's height before adding any children is 0")
assert_raise(ArgumentError) { Tree::TreeNode.new(nil) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def test_root\n setup_test_tree\n\n # TODO: Should probably change this logic. Root's root should\n # return nil so that the possibility of a recursive error does not exist\n # at all.\n assert_same(@root , @root.root, \"Root's root is self\")\n assert_same(@root , @child1.root, \"Root should be ROOT\")\n assert_same(@root , @child4.root, \"Root should be ROOT\")\n assert_equal(2 , @root.node_height, \"Root's height after adding the children should be 2\")\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def is_root?\n \troot == id\n end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def enforce_root(root); end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_tree_starts_empty\n tree = BinarySearchTree.new\n assert_nil tree.root\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def test_remove_all_bang\n setup_test_tree\n assert(@root.has_children?, \"Should have children\")\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_root_hash_when_its_empty\n assert_equal(\n 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',\n MT::Tree.new.root_hash\n )\n end",
"def is_root?()\n return (name.nil? and parent.nil?) \n end",
"def test_node_starts_with_empty_branches\n node = Node.new(50, \"movie a\")\n refute node.left_node\n refute node.right_node\n end",
"def has_root?\n @root != nil\n end",
"def test_first_child\n setup_test_tree\n\n assert_equal(@child1, @root.first_child, \"Root's first child is Child1\")\n assert_nil(@child1.first_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.first_child, \"Child3's first child is Child4\")\n end",
"def root?\n !parent\n end",
"def root_node; end",
"def leaf?; false end",
"def test_initialize\n assert_not_nil(@root, \"Binary tree's Root should have been created\")\n assert_nil(@root.left_child, \"The initial left child of root should be nil\")\n assert_nil(@root.right_child, \"The initial right child of root should be nil\")\n assert_equal(@root.children.size, 0, \"Initially no children should be present\")\n end",
"def root?\n self.parent ? false : true\n end",
"def root?\n !has_parent?\n end",
"def is_empty\n @root == nil\n end",
"def root?\n root == self\n end",
"def leaf?\n self.children.size == 0\n end",
"def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end",
"def root?\n self.depth.zero?\n end",
"def root?\n self.depth.zero?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def include_root?\n min_depth == 0\n end",
"def empty?\n @root.empty? && @root.leaf?\n end",
"def is_leaf\n true\n end",
"def is_leaf\n true\n end",
"def test_indexed_access\n setup_test_tree\n\n assert_equal(@child1, @root[0], \"Should be the first child\")\n assert_equal(@child4, @root[2][0], \"Should be the grandchild\")\n assert_nil(@root[\"TEST\"], \"Should be nil\")\n assert_nil(@root[99], \"Should be nil\")\n assert_raise(ArgumentError) { @root[nil] }\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def root?\n self.parent.nil?\n end",
"def _is_root_node?\n @nodes.size == 1\n end",
"def is_root?\n parent_id.nil?\n end",
"def is_root?\n parent_id.nil?\n end",
"def root?\r\n\t\treturn parent == nil\r\n\tend",
"def is_root?\n false\n end",
"def is_root?\n @parent.nil?\n end",
"def root?\n @type == ROOT\n end",
"def assert_leaf(node)\n assert node.element_children.empty?, 'expected no children', node\n end",
"def root?\n prev.nil? && self.next.nil?\n end",
"def root?\n false\n end",
"def root?\n depth == 1\n end",
"def child?\n !root?\n end",
"def is_root?\n self.parent_id.nil?\n end",
"def preserve_children?\n false\n end",
"def test_with_node_none\r\n link1 = @linklist.add_link(@node1, @node2)\r\n link2 = @linklist.add_link(@node2, @node3) \r\n \r\n assert(@linklist.with_node(@node4).length == 0)\r\n end",
"def test_remove_from_parent_bang\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert(!@root.is_leaf?, \"Root is not a leaf here\")\n\n child1 = @root[0]\n assert_not_nil(child1, \"Child 1 should exist\")\n assert_same(@root, child1.root, \"Child 1's root should be ROOT\")\n assert(@root.include?(child1), \"root should have child1\")\n child1.remove_from_parent!\n assert_same(child1, child1.root, \"Child 1's root should be self\")\n assert(!@root.include?(child1), \"root should not have child1\")\n\n child1.remove_from_parent!\n assert_same(child1, child1.root, \"Child 1's root should still be self\")\n end",
"def test_lt2 # Test the << method\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n assert_not_nil(@root['Child1'], \"Child 1 should have been added to Root\")\n assert_not_nil(@root['Child2'], \"Child 2 should have been added to Root\")\n assert_not_nil(@root['Child3'], \"Child 3 should have been added to Root\")\n assert_not_nil(@child3['Child4'], \"Child 4 should have been added to Child3\")\n end",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def test_parentage\n setup_test_tree\n\n assert_nil(@root.parentage, \"Root does not have any parentage\")\n assert_equal([@root], @child1.parentage, \"Child1 has Root as its parent\")\n assert_equal([@child3, @root], @child4.parentage, \"Child4 has Child3 and Root as ancestors\")\n end",
"def initialize\n @root = nil\n end",
"def empty?\n @root.nil?\n end",
"def leaf?\n children.empty?\n end",
"def empty?\n @root.nil?\n end",
"def root?\n parent_id = self[nested_set_parent]\n (parent_id == 0 || parent_id.nil?) && (self[nested_set_left] == 1) && (self[nested_set_right] > self[nested_set_left])\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def test_add_node_to_self_as_child\n root = Tree::TreeNode.new(\"root\")\n\n # Lets check the direct parentage scenario\n assert_raise(ArgumentError) {root << root}\n\n # And now a scenario where the node addition is done down the hierarchy\n # @todo This scenario is not yet fixed.\n child = Tree::TreeNode.new(\"child\")\n root << child << root\n # puts root # This will throw a stack trace\n end",
"def test_children\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n assert(!@child3.is_leaf?, \"Should not be a leaf\")\n\n assert_equal(1, @child3.node_height, \"The subtree at Child 3 should have a height of 1\")\n for child in [@child1, @child2, @child4]\n assert_equal(0, child.node_height, \"The subtree at #{child.name} should have a height of 0\")\n end\n\n children = []\n for child in @root.children\n children << child\n end\n\n assert_equal(3, children.length, \"Should have three direct children\")\n assert(!children.include?(@root), \"Should not have root\")\n assert(children.include?(@child1), \"Should have child 1\")\n assert(children.include?(@child2), \"Should have child 2\")\n assert(children.include?(@child3), \"Should have child 3\")\n assert(!children.include?(@child4), \"Should not have child 4\")\n\n children.clear\n children = @root.children\n assert_equal(3, children.length, \"Should have three children\")\n end",
"def root?\n parent_id.nil?\n end",
"def root?\n parent_id.nil?\n end",
"def child?\n !root?\n end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def get_root()\n \n end",
"def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end",
"def valid_tree?\n false\n end",
"def root?\n id == Id::ROOT\n end",
"def root?\n parent.on_node { |p| p }.nil?\n end",
"def test_peers\n root = Document.new(Font.new(Font::ROMAN, 'Arial'))\n nodes = []\n nodes.push(root.paragraph)\n nodes.push(root.bold)\n nodes.push(root.underline)\n\n assert(root.previous_node == nil)\n assert(root.next_node == nil)\n assert(nodes[1].previous_node == nodes[0])\n assert(nodes[1].next_node == nodes[2])\n end",
"def is_root?\n return call_ancestry_method(:is_root?) if use_ancestry?\n\n rel = relationship # TODO: Handle a node that is a root and a node at the same time\n rel.nil? ? true : rel.is_root?\n end",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def test_remove_bang\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove!(@child1)\n assert_equal(2, @root.size, \"Should have two nodes\")\n @root.remove!(@child2)\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n # Some negative testing\n @root.remove!(nil)\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def root?\n true\n end",
"def leaf?\n @children.empty?\n end",
"def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end",
"def leaf?\n true\n end",
"def leaf?(r)\n r.children.empty?\n end",
"def is_leaf?\n self.left_child == nil and\n self.right_child == nil\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def root?\n false\n end",
"def root?\n @parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def leaf?\n @children.length.zero?\n end",
"def root_relation?; !parent end",
"def test_node_1_has_0_ancestors_after_building_ancestors_ids_attribute\n id=1\n assert_equal 0, find_node(id).ancestors.size\n assert find_node(id).update_ancestor_ids\n assert_equal 0, find_node(id).ancestors.size\n end",
"def root?\n parent_id.nil?\n end"
] |
[
"0.7407995",
"0.7389919",
"0.7373433",
"0.7280292",
"0.7200388",
"0.7115901",
"0.6971962",
"0.695324",
"0.69144",
"0.68989855",
"0.6871652",
"0.68547374",
"0.68253666",
"0.6782645",
"0.67319846",
"0.6723097",
"0.6713372",
"0.66674066",
"0.6662848",
"0.66329324",
"0.6630796",
"0.66287816",
"0.66238093",
"0.65897053",
"0.6587099",
"0.6571226",
"0.6551294",
"0.6549458",
"0.65464765",
"0.65229595",
"0.65229595",
"0.651775",
"0.651775",
"0.651775",
"0.6514531",
"0.6508084",
"0.65036076",
"0.65036076",
"0.64839864",
"0.6480031",
"0.6480031",
"0.6445128",
"0.64414155",
"0.6435737",
"0.6414264",
"0.6414264",
"0.6404546",
"0.64011145",
"0.63967454",
"0.6396195",
"0.6375813",
"0.6367171",
"0.6366848",
"0.63618004",
"0.63537854",
"0.6353415",
"0.6341815",
"0.63399684",
"0.6332078",
"0.63236374",
"0.6323075",
"0.6313404",
"0.62999415",
"0.62917495",
"0.62903196",
"0.6289573",
"0.62869537",
"0.62865263",
"0.6285847",
"0.62821406",
"0.62747276",
"0.62747276",
"0.62718004",
"0.62686837",
"0.62645626",
"0.6264222",
"0.6262091",
"0.6258354",
"0.62575054",
"0.6252628",
"0.62510747",
"0.62508005",
"0.6247201",
"0.6243375",
"0.6243312",
"0.6242118",
"0.6241766",
"0.6238006",
"0.623637",
"0.6231482",
"0.62295866",
"0.62263846",
"0.6224098",
"0.6224098",
"0.6224098",
"0.6224098",
"0.6223987",
"0.62211245",
"0.6219223",
"0.6213449"
] |
0.7034719
|
6
|
This test is for the state after the children are linked to the root.
|
def test_root
setup_test_tree
# TODO: Should probably change this logic. Root's root should
# return nil so that the possibility of a recursive error does not exist
# at all.
assert_same(@root , @root.root, "Root's root is self")
assert_same(@root , @child1.root, "Root should be ROOT")
assert_same(@root , @child4.root, "Root should be ROOT")
assert_equal(2 , @root.node_height, "Root's height after adding the children should be 2")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def test_slide_1\n TaxonName.slide(2, 3)\n assert_equal 6, @child_middle.reload.l\n TaxonName.slide(-2, 3)\n assert @root_node.reload.check_subtree\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def test_children\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n assert(!@child3.is_leaf?, \"Should not be a leaf\")\n\n assert_equal(1, @child3.node_height, \"The subtree at Child 3 should have a height of 1\")\n for child in [@child1, @child2, @child4]\n assert_equal(0, child.node_height, \"The subtree at #{child.name} should have a height of 0\")\n end\n\n children = []\n for child in @root.children\n children << child\n end\n\n assert_equal(3, children.length, \"Should have three direct children\")\n assert(!children.include?(@root), \"Should not have root\")\n assert(children.include?(@child1), \"Should have child 1\")\n assert(children.include?(@child2), \"Should have child 2\")\n assert(children.include?(@child3), \"Should have child 3\")\n assert(!children.include?(@child4), \"Should not have child 4\")\n\n children.clear\n children = @root.children\n assert_equal(3, children.length, \"Should have three children\")\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end",
"def test_lt2 # Test the << method\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n assert_not_nil(@root['Child1'], \"Child 1 should have been added to Root\")\n assert_not_nil(@root['Child2'], \"Child 2 should have been added to Root\")\n assert_not_nil(@root['Child3'], \"Child 3 should have been added to Root\")\n assert_not_nil(@child3['Child4'], \"Child 4 should have been added to Child3\")\n end",
"def test_first_child\n setup_test_tree\n\n assert_equal(@child1, @root.first_child, \"Root's first child is Child1\")\n assert_nil(@child1.first_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.first_child, \"Child3's first child is Child4\")\n end",
"def test_breadth\n assert_equal(1, @root.breadth, \"A single node's breadth is 1\")\n\n @root << @child1\n assert_equal(1, @root.breadth, \"This should be of breadth 1\")\n\n @root << @child2\n assert_equal(2, @child1.breadth, \"This should be of breadth 2\")\n assert_equal(2, @child2.breadth, \"This should be of breadth 2\")\n\n @root << @child3\n assert_equal(3, @child1.breadth, \"This should be of breadth 3\")\n assert_equal(3, @child2.breadth, \"This should be of breadth 3\")\n\n @child3 << @child4\n assert_equal(1, @child4.breadth, \"This should be of breadth 1\")\n end",
"def test_add_node_to_self_as_child\n root = Tree::TreeNode.new(\"root\")\n\n # Lets check the direct parentage scenario\n assert_raise(ArgumentError) {root << root}\n\n # And now a scenario where the node addition is done down the hierarchy\n # @todo This scenario is not yet fixed.\n child = Tree::TreeNode.new(\"child\")\n root << child << root\n # puts root # This will throw a stack trace\n end",
"def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end",
"def test_node_1_has_0_ancestors_after_building_ancestors_ids_attribute\n id=1\n assert_equal 0, find_node(id).ancestors.size\n assert find_node(id).update_ancestor_ids\n assert_equal 0, find_node(id).ancestors.size\n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def test_last_child\n setup_test_tree\n\n assert_equal(@child3, @root.last_child, \"Root's last child is Child3\")\n assert_nil(@child1.last_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.last_child, \"Child3's last child is Child4\")\n end",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def test_children\n #puts \"---------------test_children-----------------\"\n t= {}\n\n batch11 = MyResource.new :batch11\n batch12 = MyResource.new :batch12\n batch21 = MyResource.new :batch21\n batch22 = MyResource.new :batch22\n pos1 = MyResource.new :pos1, [ batch11, batch12 ]\n pos2 = MyResource.new :pos2, [ batch21, batch22 ]\n order = MyResource.new :order, [pos1, pos2]\n\n GraphBuilder::Builder.build do |b|\n t[:order] = [ b.add(Thing0.new(order)) ]\n \n b.children do |pos|\n t[pos.name] = b.add Thing1.new(pos)\n b.children do |batch|\n b1 = b.add Thing11.new(batch)\n b2 = b.add Thing12.new(batch)\n t[batch.name] = [b1, b2]\n end\n end\n t[:order] << b.add( Thing2.new(order))\n end\n\n r = Thing.links(t.values.flatten)\n assert_instance_of Thing0, t[:order].first\n assert_instance_of Thing2, t[:order].last\n assert_instance_of Thing1, t[:pos1]\n assert_instance_of Thing1, t[:pos2]\n assert_instance_of Thing11, t[:batch11].first\n assert_instance_of Thing12, t[:batch12].last\n assert_instance_of Thing11, t[:batch21].first\n assert_instance_of Thing12, t[:batch22].last\n\n assert r.include? [t[:order].first,t[:pos1]]\n assert r.include? [t[:order].first,t[:pos2]]\n assert r.include? [t[:pos1],t[:batch11].first]\n assert r.include? [t[:pos1],t[:batch12].first]\n assert r.include? [t[:pos2],t[:batch21].first]\n assert r.include? [t[:pos2],t[:batch22].first]\n assert r.include? [t[:batch11].first,t[:batch11].last]\n assert r.include? [t[:batch12].first,t[:batch12].last]\n assert r.include? [t[:batch21].first,t[:batch21].last]\n assert r.include? [t[:batch22].first,t[:batch22].last]\n assert r.include? [t[:batch11].last,t[:order].last]\n assert r.include? [t[:batch12].last,t[:order].last]\n assert r.include? [t[:batch21].last,t[:order].last]\n assert r.include? [t[:batch22].last,t[:order].last]\n\n assert_equal 14, r.size\n end",
"def test_remove_all_bang\n setup_test_tree\n assert(@root.has_children?, \"Should have children\")\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_parentage\n setup_test_tree\n\n assert_nil(@root.parentage, \"Root does not have any parentage\")\n assert_equal([@root], @child1.parentage, \"Child1 has Root as its parent\")\n assert_equal([@child3, @root], @child4.parentage, \"Child4 has Child3 and Root as ancestors\")\n end",
"def test_initialize\n assert_not_nil(@root, \"Binary tree's Root should have been created\")\n assert_nil(@root.left_child, \"The initial left child of root should be nil\")\n assert_nil(@root.right_child, \"The initial right child of root should be nil\")\n assert_equal(@root.children.size, 0, \"Initially no children should be present\")\n end",
"def preserve_children?\n false\n end",
"def test_save_tree\n end",
"def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_sibling, \"Child2's last sibling should be child3\")\n assert_same(@child3, @child3.last_sibling, \"Child3's last sibling should be itself\")\n assert_same(@child4, @child4.last_sibling, \"Child4's last sibling should be itself\")\n assert_not_same(@child3, @child4.last_sibling, \"Child4's last sibling is itself\")\n end",
"def test_indexed_access\n setup_test_tree\n\n assert_equal(@child1, @root[0], \"Should be the first child\")\n assert_equal(@child4, @root[2][0], \"Should be the grandchild\")\n assert_nil(@root[\"TEST\"], \"Should be nil\")\n assert_nil(@root[99], \"Should be nil\")\n assert_raise(ArgumentError) { @root[nil] }\n end",
"def test_root_setup\n assert_not_nil(@root , \"Root cannot be nil\")\n assert_nil(@root.parent , \"Parent of root node should be nil\")\n assert_not_nil(@root.name , \"Name should not be nil\")\n assert_equal(\"ROOT\" , @root.name, \"Name should be 'ROOT'\")\n assert_equal(\"Root Node\" , @root.content, \"Content should be 'Root Node'\")\n assert(@root.is_root? , \"Should identify as root\")\n assert(!@root.has_children? , \"Cannot have any children\")\n assert(@root.has_content? , \"This root should have content\")\n assert_equal(1 , @root.size, \"Number of nodes should be one\")\n assert_equal(0, @root.siblings.length, \"This root does not have any children\")\n assert_equal(0, @root.in_degree, \"Root should have an in-degree of 0\")\n assert_equal(0, @root.node_height, \"Root's height before adding any children is 0\")\n assert_raise(ArgumentError) { Tree::TreeNode.new(nil) }\n end",
"def test_size\n assert_equal(1, @root.size, \"Root's size should be 1\")\n setup_test_tree\n\n assert_equal(5, @root.size, \"Root's size should be 5\")\n assert_equal(2, @child3.size, \"Child 3's size should be 2\")\n end",
"def test_movie_valid_parent\n movie = Movie.find( movies(:king_kong).id )\n parent = Movie.find( movies(:batman_series).id )\n movie.parent = parent\n assert movie.save\n assert_equal( 2, parent.children.size )\n end",
"def test_freeze_tree_bang\n setup_test_tree\n\n @root.content = \"ABC\"\n assert_equal(\"ABC\", @root.content, \"Content should be 'ABC'\")\n @root.freeze_tree!\n # Note: The error raised here depends on the Ruby version.\n # For Ruby > 1.9, RuntimeError is raised\n # For Ruby ~ 1.8, TypeError is raised\n assert_raise(RuntimeError, TypeError) {@root.content = \"123\"}\n assert_raise(RuntimeError, TypeError) {@root[0].content = \"123\"}\n end",
"def test_node_height\n assert_equal(0, @root.node_height, \"A single node's height is 0\")\n\n @root << @child1\n assert_equal(1, @root.node_height, \"This should be of height 1\")\n assert_equal(0, @child1.node_height, \"This should be of height 0\")\n\n @root << @child2\n assert_equal(1, @root.node_height, \"This should be of height 1\")\n assert_equal(0, @child2.node_height, \"This should be of height 0\")\n\n @child2 << @child3\n assert_equal(2, @root.node_height, \"This should be of height 2\")\n assert_equal(1, @child2.node_height, \"This should be of height 1\")\n assert_equal(0, @child3.node_height, \"This should be of height 0\")\n\n @child3 << @child4\n assert_equal(3, @root.node_height, \"This should be of height 3\")\n assert_equal(2, @child2.node_height, \"This should be of height 2\")\n assert_equal(1, @child3.node_height, \"This should be of height 1\")\n assert_equal(0, @child4.node_height, \"This should be of height 0\")\n end",
"def test_remove_from_parent_bang\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert(!@root.is_leaf?, \"Root is not a leaf here\")\n\n child1 = @root[0]\n assert_not_nil(child1, \"Child 1 should exist\")\n assert_same(@root, child1.root, \"Child 1's root should be ROOT\")\n assert(@root.include?(child1), \"root should have child1\")\n child1.remove_from_parent!\n assert_same(child1, child1.root, \"Child 1's root should be self\")\n assert(!@root.include?(child1), \"root should not have child1\")\n\n child1.remove_from_parent!\n assert_same(child1, child1.root, \"Child 1's root should still be self\")\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def leaf?; false end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def rearrange_children\n if rearrange_children?\n self.disable_timestamp_callback()\n self.children.each do |child|\n child.update_path!\n child.save\n # child.reload # might not need to reload?\n end\n self.enable_timestamp_callback()\n end\n @rearrange_children = false\n true\n end",
"def display_parent_child_test_cases\n \n end",
"def is_leaf\n true\n end",
"def is_leaf\n true\n end",
"def test_create_new\n @bill.save # gives us a root\n @bill.reload\n\n person = Person.find(1)\n person.editable_taxon_names << @bill\n person.reload\n # let Person edit the root. \n\n assert_equal 0, @bill.children.size\n @foo = TaxonName.create_new(\n :taxon_name => {:name => \"Bob\", :iczn_group => \"genus\", :year => '1910', :parent_id => @bill.id},\n :person => person)\n \n @foo.reload\n @bill.reload\n assert_equal @bill, @foo.parent\n assert_equal \"Bob\", @foo.name\n assert_equal 1, @bill.children.size\n end",
"def test_level\n assert_equal(0, @root.level, \"A root node's level is 0\")\n\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n\n setup_test_tree\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.level, \"Node #{child.name} should have level 1\")\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n end\n\n assert_equal(2, @child4.level, \"Child 4 should have level 2\")\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def test_detached_subtree_copy\n setup_test_tree\n\n assert(@root.has_children?, \"The root should have children.\")\n tree_copy = @root.detached_subtree_copy\n\n assert_equal(@root.name, tree_copy.name, \"The names should be equal.\")\n assert_not_equal(@root.object_id, tree_copy.object_id, \"Object_ids should differ.\")\n assert(tree_copy.is_root?, \"Copied root should be a root node.\")\n assert(tree_copy.has_children?, \"Copied tree should have children.\")\n assert_equal(tree_copy.children.count, @root.children.count, \"Copied tree and the original tree should have same number of children.\")\n\n assert_equal(tree_copy[0].name, @child1.name, \"The names of Child1 (original and copy) should be same.\")\n assert_not_equal(tree_copy[0].object_id, @child1.object_id, \"Child1 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[0].is_root?, \"Child1 copied should not be root.\")\n assert(!tree_copy[0].has_children?, \"Child1 copied should not have children.\")\n\n assert_equal(tree_copy[1].name, @child2.name, \"The names of Child2 (original and copy) should be same.\")\n assert_not_equal(tree_copy[1].object_id, @child2.object_id, \"Child2 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[1].is_root?, \"Child2 copied should not be root.\")\n assert(!tree_copy[1].has_children?, \"Child2 copied should not have children.\")\n\n assert_equal(tree_copy[2].name, @child3.name, \"The names of Child3 (original and copy) should be same.\")\n assert_not_equal(tree_copy[2].object_id, @child3.object_id, \"Child3 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[2].is_root?, \"Child3 copied should not be root.\")\n assert(tree_copy[2].has_children?, \"Child3 copied should have children.\")\n\n assert_equal(tree_copy[2][0].name, @child4.name, \"The names of Child4 (original and copy) should be same.\")\n assert_not_equal(tree_copy[2][0].object_id, @child4.object_id, \"Child4 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[2][0].is_root?, \"Child4 copied should not be root.\")\n assert(!tree_copy[2][0].has_children?, \"Child4 copied should not have children.\")\n end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def test_add\n assert(!@root.has_children?, \"Should not have any children\")\n\n assert_equal(1, @root.size, \"Should have 1 node (the root)\")\n @root.add(@child1)\n\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root << @child3 << @child4\n\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert_equal(2, @child3.size, \"Should have two nodes\")\n\n # Test the addition of a duplicate node (duplicate being defined as a node with the same name).\n assert_raise(RuntimeError) { @root.add(Tree::TreeNode.new(@child1.name)) }\n\n # Test the addition of a nil node.\n assert_raise(ArgumentError) { @root.add(nil) }\n end",
"def leaf?; @leaf; end",
"def test_detached_copy\n setup_test_tree\n\n assert(@root.has_children?, \"The root should have children\")\n copy_of_root = @root.detached_copy\n assert(!copy_of_root.has_children?, \"The copy should not have children\")\n assert_equal(@root.name, copy_of_root.name, \"The names should be equal\")\n\n # Try the same test with a child node\n assert(!@child3.is_root?, \"Child 3 is not a root\")\n assert(@child3.has_children?, \"Child 3 has children\")\n copy_of_child3 = @child3.detached_copy\n assert(copy_of_child3.is_root?, \"Child 3's copy is a root\")\n assert(!copy_of_child3.has_children?, \"Child 3's copy does not have children\")\n end",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def test_index # Test the [] method\n assert_raise(ArgumentError) {@root[nil]}\n\n @root << @child1\n @root << @child2\n assert_equal(@child1.name, @root['Child1'].name, \"Child 1 should be returned\")\n assert_equal(@child1.name, @root[0].name, \"Child 1 should be returned\")\n assert_equal(@child1.name, @root[-2].name, \"Child 1 should be returned\") # Negative access also works\n assert_equal(@child1.name, @root[-(@root.children.size)].name, \"Child 1 should be returned\") # Negative access also works\n\n assert_equal(@child2.name, @root['Child2'].name, \"Child 2 should be returned\")\n assert_equal(@child2.name, @root[1].name, \"Child 2 should be returned\")\n assert_equal(@child2.name, @root[-1].name, \"Child 2 should be returned\") # Negative access also works\n\n assert_nil(@root['Some Random Name'], \"Should return nil\")\n assert_nil(@root[99], \"Should return nil\")\n assert_nil(@root[-(@root.children.size+1)], \"Should return nil\")\n assert_nil(@root[-3], \"Should return nil\")\n end",
"def test_set_and_save\n # set_and_save sets the depth, the thread, and adds as a child if it's a reply to a comment\n comment = new_comment\n comment.set_and_save\n assert_equal 0, comment.depth\n child = new_comment(:commentable_type => 'Comment', :commentable_id => comment.id)\n child.set_and_save\n assert_equal 1, child.depth\n assert_equal comment.thread, child.thread\n assert_contains(Comment.find(comment.id).all_children, child)\n # TODO more tests for depth and add_child under different circumstances\n end",
"def assert_leaf(node)\n assert node.element_children.empty?, 'expected no children', node\n end",
"def leaf?\n self.children.size == 0\n end",
"def apply_children\n \n end",
"def children\n @root.children & @initial_contents\n end",
"def leaf?\n record.persisted? && if children.loaded? || tree.columns.counter_cache?\n # no SQL-queries here\n children.empty?\n else\n !children.exists?\n end\n end",
"def children() []; end",
"def leaf?\n persisted? && if children_counter_cache_column\n self[children_counter_cache_column] == 0\n else\n children.count == 0\n end\n end",
"def any_child_open?\n self.children.each do |e|\n return true unless e.completed\n end\n false\n end",
"def has_children?\n !leaf?\n end",
"def test_remove_bang\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove!(@child1)\n assert_equal(2, @root.size, \"Should have two nodes\")\n @root.remove!(@child2)\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n # Some negative testing\n @root.remove!(nil)\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end",
"def test_should_block_recursion_in_tree\n group = Group.find @greeks_group.id\n\n assert_raises(RecursionInTree) { group.parent = Group.find @cretes_group.id }\n end",
"def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end",
"def rearrange_children?\n !!@rearrange_children\n end",
"def test_sort_by_ancestry_missing_parent_middle_of_tree\n AncestryTestDatabase.with_model do |model|\n n1, _, _, n4, n5, _ = build_tree(model)\n\n records = model.sort_by_ancestry([n5, n4, n1])\n if CORRECT\n assert_equal [n1, n4, n5].map(&:id), records.map(&:id)\n else\n assert_equal [n1, n5, n4].map(&:id), records.map(&:id)\n end\n end\n end",
"def test_peers\n root = Document.new(Font.new(Font::ROMAN, 'Arial'))\n nodes = []\n nodes.push(root.paragraph)\n nodes.push(root.bold)\n nodes.push(root.underline)\n\n assert(root.previous_node == nil)\n assert(root.next_node == nil)\n assert(nodes[1].previous_node == nodes[0])\n assert(nodes[1].next_node == nodes[2])\n end",
"def test_unbalanced_child_gets_returned_if_exists\n parent = @system.base\n assert_equal @system.get_by_name(\"ugml\"), @system.unbalanced_child(parent)\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def do_deprecated_depth\n assert_equal(1, @root.depth, \"A single node's depth is 1\")\n\n @root << @child1\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @root << @child2\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @child2 << @child3\n assert_equal(3, @root.depth, \"This should be of depth 3\")\n assert_equal(2, @child2.depth, \"This should be of depth 2\")\n\n @child3 << @child4\n assert_equal(4, @root.depth, \"This should be of depth 4\")\n end",
"def leaf?\n @children.length.zero?\n end",
"def test_tree_starts_empty\n tree = BinarySearchTree.new\n assert_nil tree.root\n end",
"def children\n child_check\n super\n end",
"def process_child_nodes(node); end",
"def test_parent\n setup_test_tree\n\n assert_nil(@root.parent, \"Root's parent should be nil\")\n assert_equal(@root, @child1.parent, \"Parent should be root\")\n assert_equal(@root, @child3.parent, \"Parent should be root\")\n assert_equal(@child3, @child4.parent, \"Parent should be child3\")\n assert_equal(@root, @child4.parent.parent, \"Parent should be root\")\n end",
"def after_create\n self.reference_board.unique_children.each do |board|\n state = State.find_by_reference_board(board.board)\n if state.nil?\n state = State.create(:reference_board => board)\n end\n self.children << state\n end\n end",
"def test_root_hash_when_its_empty\n assert_equal(\n 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',\n MT::Tree.new.root_hash\n )\n end",
"def test_json_serialization\n setup_test_tree\n\n expected_json = {\n \"name\" => \"ROOT\",\n \"content\" => \"Root Node\",\n JSON.create_id => \"Tree::TreeNode\",\n \"children\" => [\n {\"name\" => \"Child1\", \"content\" => \"Child Node 1\", JSON.create_id => \"Tree::TreeNode\"},\n {\"name\" => \"Child2\", \"content\" => \"Child Node 2\", JSON.create_id => \"Tree::TreeNode\"},\n {\n \"name\" => \"Child3\",\n \"content\" => \"Child Node 3\",\n JSON.create_id => \"Tree::TreeNode\",\n \"children\" => [\n {\"name\" => \"Child4\", \"content\" => \"Grand Child 1\", JSON.create_id => \"Tree::TreeNode\"}\n ]\n }\n ]\n }.to_json\n\n assert_equal(expected_json, @root.to_json)\n end",
"def teardown\n @root.remove!(@left_child1)\n @root.remove!(@right_child1)\n @root = nil\n end",
"def leaf?\n true\n end",
"def leaf?\n @children.empty?\n end"
] |
[
"0.68895394",
"0.683684",
"0.67910427",
"0.6727221",
"0.6662147",
"0.66272247",
"0.66171277",
"0.6581025",
"0.6580105",
"0.65084946",
"0.64351",
"0.6410759",
"0.63753045",
"0.6370954",
"0.6313798",
"0.62765545",
"0.62703997",
"0.62565684",
"0.625236",
"0.6242969",
"0.61745644",
"0.61484283",
"0.6145475",
"0.61260664",
"0.60905784",
"0.60817856",
"0.6074187",
"0.6070516",
"0.6069685",
"0.6057483",
"0.6052132",
"0.60377204",
"0.60206336",
"0.6013417",
"0.6001658",
"0.5979954",
"0.5950667",
"0.5946007",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.5927612",
"0.59022063",
"0.5891993",
"0.58696914",
"0.5868275",
"0.58499765",
"0.58499765",
"0.5843528",
"0.5819713",
"0.5816327",
"0.5814536",
"0.5805889",
"0.5805889",
"0.57941586",
"0.5790504",
"0.57882273",
"0.5782709",
"0.5761242",
"0.5743293",
"0.57430965",
"0.5742563",
"0.5742229",
"0.57385194",
"0.5734142",
"0.57338595",
"0.5720958",
"0.5712302",
"0.5711654",
"0.5704109",
"0.57004434",
"0.569457",
"0.56920874",
"0.56913954",
"0.56870854",
"0.56867325",
"0.5679932",
"0.56778204",
"0.56712127",
"0.56712127",
"0.5669435",
"0.56673014",
"0.5658407",
"0.5656715",
"0.56544113",
"0.565033",
"0.56486696",
"0.56383497",
"0.5637223",
"0.56334394",
"0.56201756",
"0.5604274"
] |
0.66355586
|
5
|
Test the presence of content in the nodes.
|
def test_has_content_eh
a_node = Tree::TreeNode.new("A Node")
assert_nil(a_node.content , "The node should not have content")
assert(!a_node.has_content? , "The node should not have content")
a_node.content = "Something"
assert_not_nil(a_node.content, "The node should now have content")
assert(a_node.has_content?, "The node should now have content")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def text_content?\n @node.children.all?(&:text?)\n end",
"def text_content?\n @node.children.all? {|c| c.text?}\n end",
"def has_content?\n !content.nil?\n end",
"def node_contains_content?(node)\n node.name == '#cdata-section'\n end",
"def has_content(*elements)\n data_exists = false\n\n i = 0\n until data_exists || i >= elements.size do\n xpath = \"//#{elements[i]}\"\n i += 1\n xml_doc.xpath(xpath).each do |node|\n data_exists = true if node.content =~ /\\w/ &&\n node.content.gsub(/(\\r|\\n)/, ' ') !~ /^-\\d{1,2}$/\n end\n end\n\n data_exists\n end",
"def content?\n !content.nil? && !content.empty?\n end",
"def useless?\n content.nil? and children.empty?\n end",
"def check_if_page_has_content(content)\n\n page.should have_content(content)\n\n end",
"def has_item_content?(content)\n # TODO Stubbed - Requires definition and implementation\n end",
"def has_item_content?(content)\n # TODO Stubbed - Requires definition and implementation\n end",
"def has_content?\n ( not self.title.nil? and not self.title.length == 0 ) or \n (not self.description.nil? and not self.description.length == 0 ) or \n (not self.teaser.nil? and not self.teaser.length == 0 )\n end",
"def node?\n node.present?\n end",
"def test_has_content\n assert(!@contentless_post.has_content?)\n end",
"def have_element(search, content = nil)\n lambda do |obj|\n doc = Nokogiri.parse(obj.to_s)\n node_set = doc.search(search)\n if node_set.empty?\n false\n else\n collected_content = node_set.collect {|t| t.content }.join(' ')\n case content\n when Regexp\n collected_content =~ content\n when String\n collected_content.include?(content)\n when nil\n true\n end\n end\n end\n end",
"def contains_node?(path)\n begin\n node(path)\n return true\n rescue ElementDoesntExist => e\n return false\n end\n end",
"def empty_content?(element)\n element.texts.join.blank?\n end",
"def empty?\n nodes.empty?\n end",
"def content?(name, content)\n page = Islay::Pages.definitions[name]\n page and page.contents[content].present?\n end",
"def scanned_node?(node); end",
"def empty?\n content.empty?\n end",
"def empty?\n @content.empty?\n end",
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def empty?\n node.all('*').length.zero?\n end",
"def text_node?(node)\n node.name == \"text\"\n end",
"def has_visible_content?\n strong_memoize(:has_visible_content) do\n branches_filter(filter: :local).any? do |ref|\n begin\n ref.name && ref.target # ensures the branch is valid\n\n true\n rescue Rugged::ReferenceError\n false\n end\n end\n end\n end",
"def text_node?(element)\n !element.text? && element.all? {|c| c.text?}\n end",
"def has_children?\n @nodes && !@nodes.empty?\n end",
"def node?\n any?(&:node?)\n end",
"def empty?\n return @node == nil\n end",
"def cdata_node?(node)\n ['xhtml', 'html'].include?(node.attributes['type']) && !node.cdatas.empty?\n end",
"def text_element?(node)\n node.element? && node.attributes.empty? && node.children.size == 1 && node.children.first.text?\n end",
"def empty?\n @node == nil\n end",
"def has_content?(name)\n @has_content ||= {}\n @has_content.key?(name.to_s)\n end",
"def full?\r\n\t\tif nodes?\r\n\t\t\tnodes.each { |node|\r\n\t\t\t\tif node == nil\r\n\t\t\t\t\treturn false\r\n\t\t\t\tend\r\n\t\t\t}\r\n\t\tend\r\n\t\t\r\n\t\treturn true\r\n\tend",
"def nodes?\r\n\t\treturn !h? || (h? && root?)\r\n\tend",
"def contents_detected?\n true\n end",
"def is_empty?(node)\n node.name != 'img' && node.name != 'br' &&\n (node.text? && node.text.strip.empty? || !node.text? && node.children.empty?)\n end",
"def has_node?(node)\n has_node_with_name?(node.name)\n end",
"def nested?\n @nodes.any?\n end",
"def has_content!(name) # :nodoc:\n @has_content ||= {}\n @has_content[name.to_s] = true\n end",
"def empty?\n @contents.nil?\n \n \n \n \n end",
"def non_printable_node?(node)\n %w[style head title meta script].include?(node.name.downcase)\n end",
"def contains(node)\n return !(@nodes[node] == nil)\n end",
"def smartContentEnabled?\n smart_content_element.count > 0 \n end",
"def set_has_content()\n if !@open_elements.empty?()\n @open_elements.last().has_content = true\n end\n end",
"def has_children?(type=\"page\", content=nil)\n node = content || @content || Content.get(params[:id]) || nil\n \n if ( node && Content.all(:parent => node.id, :content_type => type).count > 0 )\n return true\n else\n return false\n end \n \n end",
"def plain_document?\n document.elements.empty?\n end",
"def matches?(node); end",
"def content_loaded?\n @content.to_bool\n end",
"def content_empty?\n return false if behaves_like_io?(@content) && @content.read.empty?\n return true if @content.class == String && @content.empty?\n\n false\n end",
"def text?\n node_type == TEXT_NODE\n end",
"def multiple_type?(node)\n node.name == 'content' && !node.attributes['type'].nil?\n end",
"def children?\n @contents.children?\n end",
"def text_node?(node)\n node.kind_of?(::REXML::Text)\n end",
"def text?\n type == TEXT_NODE\n end",
"def componentizable?(node)\n begin\n return false unless (\n %w[body article].include?(node.name.downcase) ||\n (\n node.name.downcase == \"div\" &&\n node['class'] &&\n node['class'].match(/\\barticle\\b/)\n )\n )\n end while node = node.next\n true\n end",
"def emptied?(xpath)\n node = @document.at_xpath(xpath)\n node.children.all? { |ch|\n @component_xpaths.include?(ch.path) ||\n (ch.text? && ch.content.strip.empty?)\n }\n end",
"def any_content(includes = true)\n @any_content ||= !(\n @comment.empty? &&\n @method_list.empty? &&\n @attributes.empty? &&\n @aliases.empty? &&\n @external_aliases.empty? &&\n @requires.empty? &&\n @constants.empty?\n )\n @any_content || (includes && !(@includes + @extends).empty? )\n end",
"def has_children?\n @nokogiri.children.any? {|child| child.kind_of? Nokogiri::XML::Element }\n end",
"def empty?()\n return @root.children.empty? ? true : false\n end",
"def has_text?\r\n @texts.size > 0\r\n end",
"def start_of_element? node\n node.node_type==Nokogiri::XML::Reader::TYPE_ELEMENT\n end",
"def text?\n @contents[0] == :text\n end",
"def has_node?(node)\n @node_map[node]\n end",
"def is_a_node?\n element_type == 'node'\n end",
"def blank?\n if content.respond_to?(:empty?)\n content.empty?\n else\n content.nil?\n end\n end",
"def supported?(node)\n !find_parser(node.inner_text).nil?\n end",
"def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end",
"def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end",
"def empty?\n content.stream.filtered_stream == (@tare_content_stream ||= InitialPageContent) && document.page_number > 0\n end",
"def all_inline?\n (xml.children.map(&:node_name) - inline_tags).empty?\n end",
"def is_textnode?(); @type == GRT_TEXTNODE; end",
"def homegrown_content?(document = @document)\n (document['source_ss'] || []).any? { |s| ['orbit','sorbit'].include? s }\n end",
"def homegrown_content?(document = @document)\n (document['source_ss'] || []).any? { |s| ['orbit','sorbit'].include? s }\n end",
"def node?\n @subject.node?\n end",
"def exist?(path, ctype=nil)\n @content_tree.exist? path, ctype\n end",
"def content_for_with_empty_check?(name)\n if @view_flow.get(name) == DryViews::EMPTY_CONTENT\n #add a check for empty, and return :empty, so we can switch on it for empty content\n return :empty\n elsif content_for_without_empty_check?(name)\n return true\n else\n return false\n end\n end",
"def spontaneous_content?\n true\n end",
"def spontaneous_content?\n true\n end",
"def node_exists?(name)\n exists?(\"node\", name)\n end",
"def is_text_in_section?(section, content, flag=true)\n within(\"#{section}\") do\n if flag\n assert page.has_content?(\"#{content}\"), \"Error: #{content} not found in #{section} !\"\n else\n assert !page.has_content?(\"#{content}\"), \"Error: #{content} found in #{section} !\"\n end\n end\n end",
"def list_empty?\n return (@first_node == nil) ? true : false\n end",
"def body_has_meaningful_content?(body_elt)\n body_elt && body_elt.to_s != \"<body><p></p></body>\"\n end",
"def has_elements?; end",
"def isDummyNode?(node) \n return node.name == Tag_Dummy ;\n end",
"def is_content_for? (intended_use)\n content_intended_use == intended_use\n end",
"def is_node?(obj)\n obj.respond_to?(:children) && obj.location.expression\n end",
"def start_element?\n @contents[0] == :start_element\n end",
"def content_for?(symbol)\n !content_blocks[symbol].empty?\n end",
"def content_check\n begin\n raise CompulsoryElementMissingException.new('location', source_name) if @doc.root.nil? \n raise CompulsoryElementMissingException.new('blocks', source_name) if @doc.root.elements['blocks'].nil?\n rescue => ex\n @log.error \"Incomplete location data found in datafile #{source_name}.\" + \"(\" + ex.message + \")\"\n raise\n end\n end",
"def has_xml_content\n attr_accessor :xml_content\n end",
"def content_for? key\n (defined? @content) && (@content.key? key)\n end",
"def has_node_with_name?(name)\n !find_node_by_name(name).nil?\n end",
"def has_sidebar_content?\n publications.any? || external_resources.any? || authors.corresponding.any?\n end",
"def html?\n type == HTML_DOCUMENT_NODE\n end",
"def has_elements?\n self.each_element{ |e| return true }\n return false\n end",
"def should_spit_text?\n @tags_chain.size > 0 && \n #(not @text.empty?) &&\n [\"body\", \"p\", \"br\", \"b\", HTMLConvertor.ping_tag].include?(@tags_chain.last[:name])\n end",
"def includes?(data)\n node = @head\n include_array = []\n until node.nil?\n include_array << node.data\n node = node.next_node\n end\n include_array.include?(data)\n end",
"def chef_node?\n chef_node.present?\n end",
"def inside_ignorable_element(n)\n while not n.kind_of? Nokogiri::HTML::Document and n.kind_of? Nokogiri::XML::Node and n.parent() != nil\n if ignorable_element(n)\n return true\n else\n n = n.parent\n end\n end\n false\n end"
] |
[
"0.7626888",
"0.7516905",
"0.75079936",
"0.74425876",
"0.6966598",
"0.6883407",
"0.68198645",
"0.68046916",
"0.6668258",
"0.66450804",
"0.6625135",
"0.66230035",
"0.6603954",
"0.6596043",
"0.6558029",
"0.65354013",
"0.6515779",
"0.6510004",
"0.64987457",
"0.6477516",
"0.64324766",
"0.6355701",
"0.6345862",
"0.6342592",
"0.63370377",
"0.6307897",
"0.6307444",
"0.63049924",
"0.6270662",
"0.6234962",
"0.6221425",
"0.621529",
"0.61910933",
"0.6152697",
"0.6150291",
"0.6146214",
"0.613907",
"0.61181283",
"0.61146057",
"0.6045893",
"0.60431564",
"0.6036814",
"0.6024678",
"0.6018418",
"0.60155517",
"0.60060906",
"0.60044473",
"0.59984326",
"0.5996276",
"0.5995952",
"0.59958786",
"0.5991735",
"0.59812117",
"0.5980426",
"0.59734493",
"0.59475154",
"0.5938074",
"0.5926898",
"0.5897017",
"0.58856994",
"0.5880064",
"0.58797985",
"0.58758396",
"0.587504",
"0.58694005",
"0.5866307",
"0.5865482",
"0.5835371",
"0.5835371",
"0.5833624",
"0.5830801",
"0.5827012",
"0.5821733",
"0.5821733",
"0.5816813",
"0.5813883",
"0.58036494",
"0.580246",
"0.580246",
"0.58015114",
"0.5780841",
"0.5756642",
"0.5753035",
"0.5751576",
"0.5745503",
"0.5737794",
"0.5733745",
"0.573119",
"0.5728766",
"0.57098603",
"0.5696946",
"0.56932443",
"0.56847394",
"0.56797975",
"0.5675355",
"0.5672191",
"0.5668506",
"0.566365",
"0.56588984",
"0.56570333"
] |
0.66436774
|
10
|
Test the equivalence of size and length methods.
|
def test_length_is_size
setup_test_tree
assert_equal(@root.size, @root.length, "Length and size methods should return the same result")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size(*) end",
"def size(*) end",
"def size?() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size\n length\n end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\nend",
"def size\n\n end",
"def size\n raise NotImplementedError\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n raise NotImplementedError\n end",
"def size; @size end",
"def length(*) end",
"def length(*) end",
"def size=(_); end",
"def size=(_); end",
"def expected_length?(length)\n expected == length\n end",
"def size(*args); end",
"def size\n\tend",
"def size()\n #This is a stub, used for indexing\n end",
"def length\n size\n end",
"def size\n\t\t@length\n\tend",
"def size\n end",
"def size\n end",
"def size\n self.length\n end",
"def size\n raise NotImplementedError.new\n end",
"def size\n\n\n end",
"def size\n end",
"def size= length\n #This is a stub, used for indexing\n end",
"def interpret_size(size); end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length\n size\n end",
"def length() end",
"def length() end",
"def length() end",
"def length() end",
"def size()\n #This is a stub, used for indexing\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size\n \t@size\n end",
"def size\n @size \n end",
"def size\n @size \n end",
"def test_Range_InstanceMethods_size\n\t\t# New in 2.0!\n\t\t# assert_equal(26, (1..26).size)\n\tend",
"def length()\n #This is a stub, used for indexing\n end",
"def length\n raise NotImplementedError, \"Please implement length\"\n end",
"def size\n raise Exception.new(\"This should be subclassed.\")\n end",
"def determine_length\n determine_length_support\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end"
] |
[
"0.75586134",
"0.75586134",
"0.74102986",
"0.7407792",
"0.7407792",
"0.7407792",
"0.7407792",
"0.7407792",
"0.7407792",
"0.73437035",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.7316878",
"0.71909785",
"0.71909785",
"0.71909785",
"0.71738136",
"0.7159303",
"0.71569437",
"0.7090686",
"0.7090686",
"0.7090686",
"0.7090686",
"0.7090686",
"0.7090686",
"0.7090686",
"0.70891035",
"0.70859164",
"0.7037009",
"0.7037009",
"0.702588",
"0.702588",
"0.7024469",
"0.7014022",
"0.6998673",
"0.6990624",
"0.69883984",
"0.6979505",
"0.6966307",
"0.6966307",
"0.6947161",
"0.6922796",
"0.6913817",
"0.690262",
"0.68891644",
"0.6864386",
"0.6859262",
"0.6859262",
"0.6859262",
"0.6859262",
"0.6859262",
"0.6859262",
"0.6859262",
"0.6833665",
"0.68068105",
"0.68068105",
"0.68068105",
"0.68068105",
"0.6800874",
"0.6800874",
"0.678118",
"0.67545485",
"0.67545485",
"0.6749222",
"0.6737756",
"0.67371774",
"0.6734161",
"0.671572",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466",
"0.67149466"
] |
0.7759589
|
0
|
Test the to_s method. This is probably a little fragile right now.
|
def test_to_s
a_node = Tree::TreeNode.new("A Node", "Some Content")
expected_string = "Node Name: A Node Content: Some Content Parent: <None> Children: 0 Total Nodes: 1"
assert_equal(expected_string, a_node.to_s, "The string representation should be same")
# Now test with a symbol as a key.
a_node = Tree::TreeNode.new(:Node_Name, "Some Content")
expected_string = "Node Name: Node_Name Content: Some Content Parent: <None> Children: 0 Total Nodes: 1"
assert_equal(expected_string, a_node.to_s, "The string representation should be same")
# Now test with a symbol as a key and another symbol as the content.
a_node = Tree::TreeNode.new(:Node_Name, :Content)
expected_string = "Node Name: Node_Name Content: Content Parent: <None> Children: 0 Total Nodes: 1"
assert_equal(expected_string, a_node.to_s, "The string representation should be same")
# Now test with a symbol as a key, and a hash as the content.
a_hash = {:a_key => "Some Value"}
a_node = Tree::TreeNode.new(:Node_Name, a_hash)
expected_string = "Node Name: Node_Name Content: #{a_hash} Parent: <None> Children: 0 Total Nodes: 1"
assert_equal(expected_string, a_node.to_s, "The string representation should be same")
# Lets now add a child to the previous node, and test the to_s for the child
child_node = Tree::TreeNode.new(:Child_node, "Child Node")
a_node << child_node
expected_string = "Node Name: Child_node Content: Child Node Parent: Node_Name Children: 0 Total Nodes: 1"
assert_equal(expected_string, child_node.to_s, "The string representation should be same")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def test_to_s()\n assert_equal(@empty_string,@rp0_1.to_s(),\"Keine korrekte Aufbereitung, wenn Zaehler 0 ist\")\n assert_equal(@empty_string,@rp0_2.to_s(), \"Keine korrekte Aufbereitung, wenn Wort das leere Wort ist\")\n assert_equal(@jaajaa_3,@rp1.to_s(),\"Keine korrekte Aufbereitung fuer nicht leere replizierte Strings\")\n end",
"def test_to_s\n\t\tfood1 = BasicFood.new(\"QUICHE\" , \"123\", 1)\n\t\tputs food1.to_s\n\t\tassert((food1.to_s).eql?(\"QUICHE 123\"), \"to_s test1\")\n\t\tfood1.count += 1\n\t\tassert( food1.count == 2, \"Count should = 2\")\n\t\tassert(food1.to_s.eql?(\"QUICHE (2) 246\"), \"to_s test2\")\n\tend",
"def to_s(*) end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def test_to_s\n base = Tui::Model::Base.new( 'lab1', 'val99' )\n assert base.to_s == 'val99'\n end",
"def to_str() end",
"def to_str() end",
"def to_s\n raise StandardError, \"#{self.class.name}#to_s accessed, must be redefined.\"\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s_safe(obj)\n if obj.respond_to?(:to_s)\n obj.to_s\n else\n 'to_s error'\n end\n end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_str; end",
"def to_s\n\t\t\traise NotImplementedError, \"%s does not provide an implementation of #to_s\" %\n\t\t\t\t[ self.class.name ]\n\t\tend",
"def to_s\n\t\traise \"to_s: Not Implemented\"\n\tend",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def test_to_s\n t = Tigger.instance\n assert_equal(\"I'm the only one!\", t.to_s)\n end",
"def to_str\n end",
"def to_str\n end",
"def to_str\n to_s\n end",
"def to_str\n to_s\n end",
"def test_to_s\n\t\titem1 = LogItem.new(\"PEACH\", Date.parse(\"1212-12-12\"), 1)\n\t\tassert( item1.to_s == \"1212-12-12,PEACH\" )\n\tend"
] |
[
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7174683",
"0.7109426",
"0.7042864",
"0.70329475",
"0.70329475",
"0.70329475",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.70191514",
"0.6932168",
"0.69259876",
"0.69259876",
"0.6917794",
"0.69056636",
"0.69056636",
"0.6899061",
"0.6884479",
"0.6884479",
"0.6884479",
"0.6884479",
"0.6884479",
"0.6884479",
"0.6884479",
"0.6884479",
"0.6884479",
"0.686851",
"0.6810664",
"0.67090654",
"0.67090654",
"0.67090654",
"0.6707846",
"0.67063564",
"0.67063564",
"0.6693002",
"0.6693002",
"0.66837"
] |
0.0
|
-1
|
Test the first_sibling method.
|
def test_first_sibling
setup_test_tree
# TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.
assert_same(@root, @root.first_sibling, "Root's first sibling is itself")
assert_same(@child1, @child1.first_sibling, "Child1's first sibling is itself")
assert_same(@child1, @child2.first_sibling, "Child2's first sibling should be child1")
assert_same(@child1, @child3.first_sibling, "Child3's first sibling should be child1")
assert_same(@child4, @child4.first_sibling, "Child4's first sibling should be itself")
assert_not_same(@child1, @child4.first_sibling, "Child4's first sibling is itself")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def first_sibling\n node = self\n while node.previous_sibling\n node = node.previous_sibling\n end\n return node\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def first_sibling_in_list\n self.class.asc(:position).first\n end",
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def next_sibling\n return @links[:next_sibling]\n end",
"def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend",
"def sibling; end",
"def left_sibling\n list.reverse.first(:position.lt => position)\n end",
"def first_sibling(scope = {})\n self_and_siblings(scope.merge(:limit => 1, :order => \"#{prefixed_left_col_name} ASC\")).first\n end",
"def next_sibling=(other); end",
"def assert_next_sibling(id, expected_sibling_id)\n wait_for(:message => \"id '#{id}' should be next to '#{expected_sibling_id}'\") do\n actual_sibling_id = get_eval(\"this.page().findElement('#{id}').nextSibling.id\")\n expected_sibling_id == actual_sibling_id\n end\n end",
"def insert_before(sibling)\n res = CMark.node_insert_before(@pointer, sibling.pointer)\n if res == 0 then raise NodeError, \"could not insert before\" end\n end",
"def test_first_child\n setup_test_tree\n\n assert_equal(@child1, @root.first_child, \"Root's first child is Child1\")\n assert_nil(@child1.first_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.first_child, \"Child3's first child is Child4\")\n end",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def first_element_child\n n = self.first_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end",
"def left_sibling\n siblings.filter(self.class.qualified_left_column < left).order(self.class.qualified_left_column.desc).first\n end",
"def left_sibling\n higher_items.last\n end",
"def first *a; self.child(*a) + ':first-child' end",
"def next_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n s = sibs.index(id)\n TaxonName.find(sibs[ s + 1] ) if s < sibs.length - 1\n else\n nil\n end\n end",
"def prepend_sibling(value = nil)\n raise StructureException, 'Root node can not have siblings' if root?\n\n prepend value\n self\n end",
"def next_sibling\n # Raise error in case we are root\n raise RationalNumberIsRootNoSiblingsError if root?\n\n _parent = self.parent # Get parent already to avoid duplicate calculations\n _position = ((@nv - _parent.nv) / _parent.snv) + 1\n value_from_parent_and_position(_parent, _position)\n end",
"def right_sibling\n right_siblings.first\n end",
"def move_left\n move_to_left_of left_sibling\n end",
"def left_sibling\n siblings.where(arel_table[snumv_column_name].eq(numv)).\n where(arel_table[sdenv_column_name].eq(denv)).first\n end",
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"def left_sibling\n siblings.\n where( arel[position_column].lt(self[position_column]) ).\n reorder( arel[position_column].desc ).\n first\n end",
"def next_sibling_by_date\n siblings_by_date.where(\"starts_at >= ?\", starts_at)&.first\n end",
"def previous_sibling\n return @links[:previous_sibling]\n end",
"def add_previous_sibling(node_or_tags); end",
"def previous_sibling=(other); end",
"def parse_sibling(scanner)\n parse(scanner)\n end",
"def first(path_stack, node); end",
"def first_child\n child 0\n end",
"def first?\n self.rel == \"first\"\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def is_or_is_sibling_of?(other)\n (other == self) or is_sibling_of?(other)\n end",
"def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend",
"def assert_first_page\n assert_no_link PREV_LABEL\n end",
"def validate_sibling!(other)\n unless other.is_a?(tree.base_class)\n message = \"#{tree.base_class.name} expected, got #{other.class.name}\"\n raise ActiveRecord::AssociationTypeMismatch, message\n end\n\n other.ordered_tree_node\n end",
"def is_sibling_of?(other)\n (other != self) and (other[tree_parent_id_field] == self[tree_parent_id_field])\n end",
"def node_first\n @head\n end",
"def first?\n not first.nil?\n end",
"def move_lower\n next_sib = next_sibling\n move_to_right_of(next_sib) if next_sib\n end",
"def next_element_sibling\n n = self.next_sibling\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end",
"def first() end",
"def previous_sibling\n return nil if parent.nil? # self is root\n return nil if 1 == parent.children.size # self is parent's only child\n if 0 == own_child_index\n return nil # self is first child\n else\n # return previous sibling\n parent.children[own_child_index - 1]\n end\n end",
"def has_sibling?(peer)\n false\n end",
"def add_next_sibling(node_or_tags); end",
"def sibling(name)\n parent && parent.find(name)\n end",
"def assignSiblingNode(sibling)\n\t\t@siblingNode = sibling \n\tend",
"def next_node\n children.first || successor\n end",
"def first\n @children[0]\n end",
"def previous_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n\n s = sibs.index(id)\n TaxonName.find(sibs[s - 1]) if s != 0\n else\n nil\n end\n end",
"def calculable_sibling?(edge, sibling)\n sibling == edge || sibling.demand\n end",
"def left_sibling\n base_class.first scoped(parent_column_name => _parent_id, left_column_name => { '$lt' => left }, :order => \"#{left_column_name} DESC\")\n end",
"def add_previous_sibling_and_get(node, html)\n\t\tresult = node.add_previous_sibling(make_node(html, node.document))\n\t\tresult = result[0] if result.is_a?(Array)\n\t\treturn result\n\tend",
"def previous_is? &block\n first? ? nil : yield(element, self.previous)\n end",
"def sibling_of?(node)\n self.read_attribute(self.ancestry_base_class.ancestry_column) == node.read_attribute(self.ancestry_base_class.ancestry_column)\n end",
"def first?; end",
"def first\n end",
"def first; end",
"def first; end",
"def next\n DOM::Element.from_node `#{@el}.nextElementSibling || Opal.nil`\n end",
"def find_subsequent()\n curr = self\n while !curr.next.nil?\n curr = curr.next \n return curr if yield curr\n end\n\n return nil\n end",
"def has_sibling?(peer); false end",
"def dom_class_first(object, array)\n if (object == array.first)\n return \"first\"\n end\n nil\n end",
"def move_to_top\n first_sib = first_sibling\n move_to_left_of(first_sib) if first_sib && self != first_sib\n end",
"def first\n @current = self.head if self.head\n @current.value rescue nil\n end",
"def first_part_of_call_chain(node); end",
"def first_part_of_call_chain(node); end",
"def first!\n fail_not_found_if_nil(first)\n end",
"def first\n @ordered_elements.first\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def sibling(node_id)\n node_id ^ 1\n end",
"def insert_sibling_before(el)\n raise ArgumentError.new('You tried to insert self before self') if self == el\n return nil if parent.nil? # self is root\n parent.add_child(el, own_child_index)\n end",
"def first_child?\n if mother = participant.try(:mother)\n if mother.participant?\n return mother.children.first == self\n end\n end\n false\n end",
"def move_left\n self.move_to_left_of(self.left_sibling)\n end",
"def check_alone_sibling\n self.siblinghood.destroy if self.siblinghood && self.siblinghood.students.count == 1\n end",
"def first?\n if defined? @first\n false\n else\n @first = false\n true\n end\n end",
"def right_sibling\n list.first(:position.gt => position)\n end",
"def first?\n self.previous_id.nil?\n end",
"def self_or_first_descendant\n block = self\n while block.descendant; block = block.descendant; end\n block\n end",
"def assert_not_first_page\n assert_link PREV_LABEL\n end",
"def previous_sibling_by_date\n siblings_by_date.where(\"starts_at < ?\", starts_at)&.last\n end",
"def preceding(node); end",
"def right_sibling\n siblings.filter(self.class.qualified_left_column > left).first\n end",
"def check_predecessor\n @predecessor = nil if !(@predecessor == nil || @predecessor.heartbeat != 1)\n end",
"def remove_first\n return nil if empty?\n node = @sentinel.next\n e = node.data\n node.next.prev = @sentinel\n @sentinel.next = node.next\n e\n end",
"def remove_first\n return nil if empty?\n node = @sentinel.next\n e = node.data\n node.next.prev = @sentinel\n @sentinel.next = node.next\n e\n end",
"def first_child\n children.min_by { |x| x.position}\n end",
"def next\n value = `#{@el}.nextElementSibling || false`\n value ? DOM::Element.fromNode(value) : nil\n end",
"def first_order?\n self.order_num === 1\n end",
"def first?\n return false unless in_list?\n my_position == 1\n end",
"def first?\n return false unless in_list?\n my_position == 1\n end",
"def left_sibling=(node)\n return node if record == node\n\n to = validate_sibling!(node)\n\n self.position = higher_than?(node) ? to.position : to.position + 1\n self.parent_id = to.parent_id\n\n node\n end",
"def previous_element_sibling\n n = self.previous_sibling\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.previous_sibling\n end\n return n\n end",
"def predecessor\n siblings.previous(self) || parent\n end"
] |
[
"0.79009914",
"0.7566066",
"0.7036902",
"0.69206107",
"0.6722695",
"0.6710509",
"0.6663359",
"0.6630579",
"0.65792525",
"0.65449476",
"0.63982356",
"0.6392025",
"0.6339048",
"0.63280016",
"0.6317552",
"0.6300825",
"0.62610334",
"0.6217274",
"0.62068033",
"0.62030685",
"0.6179386",
"0.61673945",
"0.61637115",
"0.61504436",
"0.6116183",
"0.6076002",
"0.60730535",
"0.60696495",
"0.60619354",
"0.60465056",
"0.60451794",
"0.6020586",
"0.6015817",
"0.6005654",
"0.59473884",
"0.594699",
"0.5918835",
"0.59005404",
"0.58561194",
"0.58551997",
"0.58505356",
"0.5830554",
"0.581278",
"0.5810293",
"0.5782156",
"0.5764082",
"0.5741958",
"0.5735131",
"0.57236254",
"0.5719402",
"0.5715374",
"0.57133913",
"0.571292",
"0.57047474",
"0.56960976",
"0.5684242",
"0.5683485",
"0.5681386",
"0.56650764",
"0.5661688",
"0.5658852",
"0.56587934",
"0.5648229",
"0.56413066",
"0.56413066",
"0.56196725",
"0.5598734",
"0.55961573",
"0.55939305",
"0.55894274",
"0.5552153",
"0.5536178",
"0.5536178",
"0.5534194",
"0.5514866",
"0.55079687",
"0.5507813",
"0.5493573",
"0.54857326",
"0.54768836",
"0.5454492",
"0.54432833",
"0.54330003",
"0.5425061",
"0.5420865",
"0.54185367",
"0.54151565",
"0.54146594",
"0.5414046",
"0.5407635",
"0.5406587",
"0.5406587",
"0.5403596",
"0.5394983",
"0.5363846",
"0.53473014",
"0.53473014",
"0.53458697",
"0.5318857",
"0.5315606"
] |
0.8353498
|
0
|
Test the is_first_sibling? method.
|
def test_is_first_sibling_eh
setup_test_tree
assert(@root.is_first_sibling?, "Root's first sibling is itself")
assert( @child1.is_first_sibling?, "Child1's first sibling is itself")
assert(!@child2.is_first_sibling?, "Child2 is not the first sibling")
assert(!@child3.is_first_sibling?, "Child3 is not the first sibling")
assert( @child4.is_first_sibling?, "Child4's first sibling is itself")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n assert_same(@child1, @child2.first_sibling, \"Child2's first sibling should be child1\")\n assert_same(@child1, @child3.first_sibling, \"Child3's first sibling should be child1\")\n assert_same(@child4, @child4.first_sibling, \"Child4's first sibling should be itself\")\n assert_not_same(@child1, @child4.first_sibling, \"Child4's first sibling is itself\")\n end",
"def first_sibling\n node = self\n while node.previous_sibling\n node = node.previous_sibling\n end\n return node\n end",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def first?\n self.rel == \"first\"\n end",
"def first?\n not first.nil?\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def first_child?\n if mother = participant.try(:mother)\n if mother.participant?\n return mother.children.first == self\n end\n end\n false\n end",
"def is_or_is_sibling_of?(other)\n (other == self) or is_sibling_of?(other)\n end",
"def first?\n if defined? @first\n false\n else\n @first = false\n true\n end\n end",
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend",
"def is_first_segment_of_flight?\n return true if sibling_segments.empty?\n sibling_segments.sort_by {|segment| segment.index }.first == self\n end",
"def next_sibling\n return @links[:next_sibling]\n end",
"def is_sibling_of?(other)\n (other != self) and (other[tree_parent_id_field] == self[tree_parent_id_field])\n end",
"def first_sibling_in_list\n self.class.asc(:position).first\n end",
"def first?\n result = @first[-1]\n @first[-1] = false\n result\n end",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def is_first_child?(question)\n answer_for(question, participant.person.is_first_child?)\n end",
"def first_element_child\n n = self.first_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end",
"def first?\n return false unless in_list?\n my_position == 1\n end",
"def first?\n return false unless in_list?\n my_position == 1\n end",
"def first?\n self.previous_id.nil?\n end",
"def has_sibling?(peer)\n false\n end",
"def first?\n position <= 1\n end",
"def first_item?\n true\n end",
"def previous_is? &block\n first? ? nil : yield(element, self.previous)\n end",
"def assert_next_sibling(id, expected_sibling_id)\n wait_for(:message => \"id '#{id}' should be next to '#{expected_sibling_id}'\") do\n actual_sibling_id = get_eval(\"this.page().findElement('#{id}').nextSibling.id\")\n expected_sibling_id == actual_sibling_id\n end\n end",
"def sibling_of?(node)\n self.read_attribute(self.ancestry_base_class.ancestry_column) == node.read_attribute(self.ancestry_base_class.ancestry_column)\n end",
"def first_order?\n self.order_num === 1\n end",
"def first?\n index == 0\n end",
"def first?\n index == 0\n end",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def first_sibling(scope = {})\n self_and_siblings(scope.merge(:limit => 1, :order => \"#{prefixed_left_col_name} ASC\")).first\n end",
"def next_is? &block\n last? ? nil : yield(element, self.next)\n end",
"def next_sibling_by_date\n siblings_by_date.where(\"starts_at >= ?\", starts_at)&.first\n end",
"def left_sibling\n list.reverse.first(:position.lt => position)\n end",
"def first?\n self.index == 0\n end",
"def test_first_child\n setup_test_tree\n\n assert_equal(@child1, @root.first_child, \"Root's first child is Child1\")\n assert_nil(@child1.first_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.first_child, \"Child3's first child is Child4\")\n end",
"def calculable_sibling?(edge, sibling)\n sibling == edge || sibling.demand\n end",
"def has_sibling?(peer); false end",
"def first?\n\t\treturn @iteration == 0\n\tend",
"def first?\n\t locate == 1\n\tend",
"def first_page?\n current_page == pages.begin\n end",
"def line_break_has_no_previous_sibling?(node)\n node.name == 'br' && node.previous_sibling.nil? &&\n node.ancestors.all? { |ancestor| ancestor.previous_sibling.nil? }\n end",
"def prepend_sibling(value = nil)\n raise StructureException, 'Root node can not have siblings' if root?\n\n prepend value\n self\n end",
"def first?\n index == 0\n end",
"def last?\n !right_sibling\n end",
"def has_next\n return !(self.next_node.nil?)\n end",
"def next_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n s = sibs.index(id)\n TaxonName.find(sibs[ s + 1] ) if s < sibs.length - 1\n else\n nil\n end\n end",
"def insert_before(sibling)\n res = CMark.node_insert_before(@pointer, sibling.pointer)\n if res == 0 then raise NodeError, \"could not insert before\" end\n end",
"def sibling; end",
"def head?\n @prev.nil?\n end",
"def left_sibling\n siblings.\n where( arel[position_column].lt(self[position_column]) ).\n reorder( arel[position_column].desc ).\n first\n end",
"def first?\n # return false unless in_list?\n self.send(position_column) == 1\n end",
"def first_item?\n self.simple_acts_as_list_scope.first == self\n end",
"def next_sibling\n # Raise error in case we are root\n raise RationalNumberIsRootNoSiblingsError if root?\n\n _parent = self.parent # Get parent already to avoid duplicate calculations\n _position = ((@nv - _parent.nv) / _parent.snv) + 1\n value_from_parent_and_position(_parent, _position)\n end",
"def start_element?\n @contents[0] == :start_element\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def has_sibling?(peer)\n\t plan.has_sibling?(peer)\n\tend",
"def first?; end",
"def left_sibling\n siblings.filter(self.class.qualified_left_column < left).order(self.class.qualified_left_column.desc).first\n end",
"def first_page?\n page == 1\n end",
"def next\n DOM::Element.from_node `#{@el}.nextElementSibling || Opal.nil`\n end",
"def check_alone_sibling\n self.siblinghood.destroy if self.siblinghood && self.siblinghood.students.count == 1\n end",
"def first_page?\n return true if total_pages < 1\n return (page == 1)\n end",
"def left_sibling\n higher_items.last\n end",
"def at_top?\n higher_siblings.empty?\n end",
"def next_sibling=(other); end",
"def next_node\n children.first || successor\n end",
"def first *a; self.child(*a) + ':first-child' end",
"def check_predecessor\n @predecessor = nil if !(@predecessor == nil || @predecessor.heartbeat != 1)\n end",
"def has_next()\n \n end",
"def has_next()\n \n end",
"def next\n value = `#{@el}.nextElementSibling || false`\n value ? DOM::Element.fromNode(value) : nil\n end",
"def has_next?()\n if @next_node\n return true\n else\n return false\n end\n end",
"def first_page?\n\t\t\t!prev_page_url if paginated?\n\t\tend",
"def left_sibling\n siblings.where(arel_table[snumv_column_name].eq(numv)).\n where(arel_table[sdenv_column_name].eq(denv)).first\n end",
"def next_element_sibling\n n = self.next_sibling\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end",
"def node_first\n @head\n end",
"def next_node_is_text?(node)\n !node.next_sibling.nil? && node.next_sibling.text? && !node.next_sibling.text.strip.empty?\n end",
"def right_sibling\n right_siblings.first\n end",
"def has_next_page\n if first\n paged_nodes.length >= first\n else\n false\n end\n end",
"def siblings?(node1, node2)\n siblings(node1).include?(node2)\n end",
"def next?\n not self.next.nil?\n end",
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def previous_node_is_text?(node)\n !node.previous_sibling.nil? && node.previous_sibling.text? && !node.previous_sibling.text.strip.empty?\n end",
"def empty?\n first == nil\n end",
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"def first_includes_eps?\n @first && @first.include?(:_eps)\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first?\n self[position_column] <= 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def has_next\n\t\tend",
"def first?\n event.user.chapters.ascending.first == self\n end",
"def dom_class_first(object, array)\n if (object == array.first)\n return \"first\"\n end\n nil\n end",
"def first_child\n child 0\n end"
] |
[
"0.8011443",
"0.7393663",
"0.68509376",
"0.67709875",
"0.6767636",
"0.6628235",
"0.6586078",
"0.65065676",
"0.64640445",
"0.6428762",
"0.6379756",
"0.6361455",
"0.63255423",
"0.6273904",
"0.6273167",
"0.62536615",
"0.6253361",
"0.62115103",
"0.61885977",
"0.61577463",
"0.61577463",
"0.6136975",
"0.61321783",
"0.6127495",
"0.61079836",
"0.6107639",
"0.60617167",
"0.60384333",
"0.6027991",
"0.60033923",
"0.60033923",
"0.6001225",
"0.60008085",
"0.59936804",
"0.5978755",
"0.5975502",
"0.5934679",
"0.5932658",
"0.59250855",
"0.59229255",
"0.5907922",
"0.59004945",
"0.58892566",
"0.5873666",
"0.5871463",
"0.5861317",
"0.5855057",
"0.58530235",
"0.5827226",
"0.5825896",
"0.58053833",
"0.58014536",
"0.579649",
"0.57938784",
"0.57790136",
"0.5777138",
"0.5773726",
"0.5773085",
"0.57524264",
"0.5748518",
"0.57461524",
"0.572543",
"0.5722574",
"0.570088",
"0.5685018",
"0.56572443",
"0.5654146",
"0.5649976",
"0.5645661",
"0.56438816",
"0.56372917",
"0.5635696",
"0.5635696",
"0.56294274",
"0.5625048",
"0.5624618",
"0.5609717",
"0.5602785",
"0.55940974",
"0.55877453",
"0.5587089",
"0.55834985",
"0.5577066",
"0.5573642",
"0.55691385",
"0.5561616",
"0.5555706",
"0.55552965",
"0.55530083",
"0.55477816",
"0.55477816",
"0.55384856",
"0.55355924",
"0.55355924",
"0.55355924",
"0.55355924",
"0.55347985",
"0.5522929",
"0.55024034",
"0.5501404"
] |
0.7982871
|
1
|
Test the is_last_sibling? method.
|
def test_is_last_sibling_eh
setup_test_tree
assert(@root.is_last_sibling?, "Root's last sibling is itself")
assert(!@child1.is_last_sibling?, "Child1 is not the last sibling")
assert(!@child2.is_last_sibling?, "Child2 is not the last sibling")
assert( @child3.is_last_sibling?, "Child3's last sibling is itself")
assert( @child4.is_last_sibling?, "Child4's last sibling is itself")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def last?\n !right_sibling\n end",
"def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_sibling, \"Child2's last sibling should be child3\")\n assert_same(@child3, @child3.last_sibling, \"Child3's last sibling should be itself\")\n assert_same(@child4, @child4.last_sibling, \"Child4's last sibling should be itself\")\n assert_not_same(@child3, @child4.last_sibling, \"Child4's last sibling is itself\")\n end",
"def last?\n self.rel == \"last\"\n end",
"def last?\n if tree.columns.counter_cache? && parent\n parent.children.size == position\n else\n !right_sibling\n end\n end",
"def last_sibling\n node = self\n while node.next_sibling\n node = node.next_sibling\n end\n return node\n end",
"def last?\n not last.nil?\n end",
"def last?\n @SuccessorReference.value.is_a? Tail\n end",
"def last?\n @last\n end",
"def last?\n @last\n end",
"def has_next?\n !self.last?\n end",
"def last?\n self.next_id.nil?\n end",
"def last?\n\t\treturn @iteration == @items.length - 1\n\tend",
"def last?\n index == size - 1\n end",
"def last?\n index == size - 1\n end",
"def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end",
"def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end",
"def at_bottom?\n lower_siblings.empty?\n end",
"def is_last_segment_of_flight?\n return true if sibling_segments.empty?\n sibling_segments.sort_by {|segment| segment.index }.reverse.first == self\n end",
"def last?\n position == bottom\n end",
"def last?\n self.index == (self.array.length - 1)\n end",
"def last?\n # return false unless in_list?\n self.send(position_column) == bottom_position_in_list\n end",
"def last_element_child\n n = self.last_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.previous_sibling\n end\n return n\n end",
"def is_last(target)\n index = @hash[target.name].index(target)\n last = @hash[target.name].size - 1\n return index == last\n end",
"def test_last_child\n setup_test_tree\n\n assert_equal(@child3, @root.last_child, \"Root's last child is Child3\")\n assert_nil(@child1.last_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.last_child, \"Child3's last child is Child4\")\n end",
"def last_item?\n self.simple_acts_as_list_scope.last == self\n end",
"def last_page?\n current_page == pages.end\n end",
"def last?\n index == @collection.length - 1\n end",
"def last=(node)\n return self.sibling = node\n end",
"def last_page?\n !next_page_url\n end",
"def end?()\n END_MARKER.equal? _next_element\n end",
"def current_is_last_page?\n @current_page.next_page == 0\n end",
"def is_before_last?(elt)\n self[self.size - 2][:page].url == elt.url or self[self.size - 2][:driver].popup_name == elt.popup_name\n end",
"def next_is? &block\n last? ? nil : yield(element, self.next)\n end",
"def last_sibling_in_list\n self.class.asc(:position).last\n end",
"def tail?\n @next_node.nil?\n end",
"def last_page?\n !out_of_bounds? && next_page.nil?\n end",
"def last_page?\n\t\t\t!next_page_url if paginated?\n\t\tend",
"def move_to_bottom\n return true if at_bottom?\n move_below(last_sibling_in_list)\n end",
"def last *a; self.child(*a) + ':last-child' end",
"def getLastNode #not counting the sentinel node\n\tunless (@size == 0)\n\t\treturn @last.prev\n\telse\n\t\treturn nil\n\tend\nend",
"def last_page?\n current_page == total_pages - 1\n end",
"def tail?\n @next.nil?\n end",
"def tail?\n @next.nil?\n end",
"def has_next\n return !(self.next_node.nil?)\n end",
"def end_element?\n @contents[0] == :end_element\n end",
"def find_last \n\t\tcurrent_node = @head\n\t\tuntil current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node\n\tend",
"def last\n self.each {|node| return node if node.next_node == nil}\n end",
"def is_last? response, page\n sess_span.include?(prev_max) || super(response, page)\n end",
"def has_tail?\n !@tail.nil?\n end",
"def assert_last_page\n assert_no_link NEXT_LABEL\n end",
"def last_node(node)\n return node if tail?\n last_node(node.next_node)\n end",
"def last\n if @nxt\n @nxt.last\n else\n self\n end\n end",
"def last_page?\n page_number < last_page_number\n end",
"def last_page?\n last_page_number.nil?\n end",
"def is_or_is_sibling_of?(other)\n (other == self) or is_sibling_of?(other)\n end",
"def last_block?\n return @last_block\n end",
"def last?\n event.user.chapters.ascending.last == self\n end",
"def last?; end",
"def last\n empty? ? nil : @anchor.prev_node.value\n end",
"def last_page?\n current_page == total_pages\n end",
"def last_page?\n response['next'].nil?\n end",
"def last_page?\n return true if total_pages < 1\n return (page == total_pages)\n end",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def has_sibling?(peer)\n false\n end",
"def last_page?\n current_page >= num_pages\n end",
"def last_page?\n current_page >= num_pages\n end",
"def is_after?(step_nr)\n return !flow.flow_step_is_before?(current_step:step, other_step:step_nr)\n end",
"def last_page?\n page == total_pages\n end",
"def find_last &predicate\n return nil unless block_given? \n current = self.tail\n while current\n return current if predicate.call(current)\n current = current.prev\n end\nend",
"def remove_last\n return nil if empty?\n node = @sentinel.prev\n e = node.data\n node.prev.next = @sentinel\n @sentinel.prev = node.prev\n e\n end",
"def remove_last\n return nil if empty?\n node = @sentinel.prev\n e = node.data\n node.prev.next = @sentinel\n @sentinel.prev = node.prev\n e\n end",
"def last_page?\n current_page == page_count\n end",
"def bottom_item(except = nil)\n except ? siblings.reject{|page| page == self }.last : siblings.last\n end",
"def last_slice?\n current_slice == slice_number\n end",
"def last_page?\n current_page >= num_pages\n end",
"def last_page?\n current_page_number == total_pages\n end",
"def line_break_has_no_previous_sibling?(node)\n node.name == 'br' && node.previous_sibling.nil? &&\n node.ancestors.all? { |ancestor| ancestor.previous_sibling.nil? }\n end",
"def last_sibling(scope = {})\n self_and_siblings(scope.merge(:limit => 1, :order => \"#{prefixed_left_col_name} DESC\")).first\n end",
"def assert_last(string, last)\n Parser.parse(string)\n Parser.last.must_equal last\n end",
"def right_sibling\n list.first(:position.gt => position)\n end",
"def covers_last?(slot)\n slot.to >= slot_last\n end",
"def last\n node = @head;\n return node if node.next.nil?\n until (node.next.nil?) #until end of list\n node = node.next\n return node if node.next.nil?\n end\n end",
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def end_with?(suffix)\n `if (self.lastIndexOf(suffix) == self.length - suffix.length) {\n return Qtrue;\n }\n\n return Qfalse;`\n end",
"def end_with?(suffix)\n `if (self.lastIndexOf(suffix) == self.length - suffix.length) {\n return Qtrue;\n }\n\n return Qfalse;`\n end",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def has_sibling?(peer); false end",
"def assert_not_last_page\n assert_link NEXT_LABEL\n end",
"def next_sibling\n return @links[:next_sibling]\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def last_question?\n assessment.questions.last == self\n end",
"def has_next?()\n if @next_node\n return true\n else\n return false\n end\n end",
"def pop_tail\n \n extraido = false\n \n if @head == nil #Comprobamos si la lista no esta vacía\n\t\t\traise RuntimeError, \"Lista vacía, no se puede extraer nodo\"\n\t\telse\n\t\t extraido = true\n\t\t\tif @head == @tail\n\t\t\t\t@head = nil\n\t\t\t\t@tail = nil\n\t\t\telse\n\t\t\t\t@tail = @tail.next\n\t\t\t\t@tail.prev = nil\n\t\t\tend\n end\n return extraido\n end",
"def last_move?\n @moves[-1]\n end",
"def last_page?\n return true\n # hack to remove this call so we don't do any counting\n #current_page >= total_pages\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def on_last_component?\n @current_component == @focusables.last\n end",
"def last?\n\t locate == self.comic.live_pages.length\n\tend",
"def last_page?\n @paging_state.nil?\n end"
] |
[
"0.83869696",
"0.76460224",
"0.73134035",
"0.7301334",
"0.7240698",
"0.6910003",
"0.6863837",
"0.6729055",
"0.6729055",
"0.66619647",
"0.6660469",
"0.6627207",
"0.6570848",
"0.6570848",
"0.6557216",
"0.6557216",
"0.65351707",
"0.65260994",
"0.64273703",
"0.64195675",
"0.63713163",
"0.6299879",
"0.6259364",
"0.6254732",
"0.624048",
"0.6226814",
"0.61918914",
"0.6115875",
"0.6097652",
"0.60837406",
"0.607705",
"0.60719043",
"0.6062652",
"0.60561544",
"0.604543",
"0.604413",
"0.60184705",
"0.6003104",
"0.59809154",
"0.59712625",
"0.59644544",
"0.59230214",
"0.59230214",
"0.5911896",
"0.5910244",
"0.5908631",
"0.5889563",
"0.58737326",
"0.5869424",
"0.58617795",
"0.5834938",
"0.58196205",
"0.5807971",
"0.57984525",
"0.57957464",
"0.57906216",
"0.57837737",
"0.5778717",
"0.57727104",
"0.5765422",
"0.5752375",
"0.5747788",
"0.5738517",
"0.57327706",
"0.5730694",
"0.5730694",
"0.5724773",
"0.57231164",
"0.57105744",
"0.5709435",
"0.5709435",
"0.5708701",
"0.5704968",
"0.57034755",
"0.57012826",
"0.5699483",
"0.56970954",
"0.56884956",
"0.5680507",
"0.56799823",
"0.5664904",
"0.56642646",
"0.56471014",
"0.56464636",
"0.56464636",
"0.5644877",
"0.5644435",
"0.5640344",
"0.5635253",
"0.5619367",
"0.5616969",
"0.56145084",
"0.5608591",
"0.56083506",
"0.5587053",
"0.55861694",
"0.55861694",
"0.5577556",
"0.55755925",
"0.5573111"
] |
0.7951246
|
1
|
Test the last_sibling method.
|
def test_last_sibling
setup_test_tree
assert_same(@root, @root.last_sibling, "Root's last sibling is itself")
assert_same(@child3, @child1.last_sibling, "Child1's last sibling should be child3")
assert_same(@child3, @child2.last_sibling, "Child2's last sibling should be child3")
assert_same(@child3, @child3.last_sibling, "Child3's last sibling should be itself")
assert_same(@child4, @child4.last_sibling, "Child4's last sibling should be itself")
assert_not_same(@child3, @child4.last_sibling, "Child4's last sibling is itself")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def last?\n !right_sibling\n end",
"def last_sibling\n node = self\n while node.next_sibling\n node = node.next_sibling\n end\n return node\n end",
"def last_sibling_in_list\n self.class.asc(:position).last\n end",
"def last?\n if tree.columns.counter_cache? && parent\n parent.children.size == position\n else\n !right_sibling\n end\n end",
"def last=(node)\n return self.sibling = node\n end",
"def test_last_child\n setup_test_tree\n\n assert_equal(@child3, @root.last_child, \"Root's last child is Child3\")\n assert_nil(@child1.last_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.last_child, \"Child3's last child is Child4\")\n end",
"def last_element_child\n n = self.last_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.previous_sibling\n end\n return n\n end",
"def last?\n self.rel == \"last\"\n end",
"def last *a; self.child(*a) + ':last-child' end",
"def left_sibling\n higher_items.last\n end",
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def next_sibling\n return @links[:next_sibling]\n end",
"def last\n empty? ? nil : @anchor.prev_node.value\n end",
"def last_sibling(scope = {})\n self_and_siblings(scope.merge(:limit => 1, :order => \"#{prefixed_left_col_name} DESC\")).first\n end",
"def getLastNode #not counting the sentinel node\n\tunless (@size == 0)\n\t\treturn @last.prev\n\telse\n\t\treturn nil\n\tend\nend",
"def right_sibling\n right_siblings.first\n end",
"def right_sibling\n list.first(:position.gt => position)\n end",
"def last?\n @SuccessorReference.value.is_a? Tail\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def last\n self.each {|node| return node if node.next_node == nil}\n end",
"def assert_last_page\n assert_no_link NEXT_LABEL\n end",
"def has_next?\n !self.last?\n end",
"def last?\n not last.nil?\n end",
"def bottom_item(except = nil)\n except ? siblings.reject{|page| page == self }.last : siblings.last\n end",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def find_last \n\t\tcurrent_node = @head\n\t\tuntil current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node\n\tend",
"def last?\n\t\treturn @iteration == @items.length - 1\n\tend",
"def last_ele tag_name\n xpath \"//#{tag_name}[last()]\"\n end",
"def last?\n self.next_id.nil?\n end",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def last_node(node)\n return node if tail?\n last_node(node.next_node)\n end",
"def remove_last_child\n @elements.pop\n end",
"def last\n if @nxt\n @nxt.last\n else\n self\n end\n end",
"def last?\n @last\n end",
"def last?\n @last\n end",
"def sibling; end",
"def remove_last\n return nil if empty?\n node = @sentinel.prev\n e = node.data\n node.prev.next = @sentinel\n @sentinel.prev = node.prev\n e\n end",
"def remove_last\n return nil if empty?\n node = @sentinel.prev\n e = node.data\n node.prev.next = @sentinel\n @sentinel.prev = node.prev\n e\n end",
"def assert_next_sibling(id, expected_sibling_id)\n wait_for(:message => \"id '#{id}' should be next to '#{expected_sibling_id}'\") do\n actual_sibling_id = get_eval(\"this.page().findElement('#{id}').nextSibling.id\")\n expected_sibling_id == actual_sibling_id\n end\n end",
"def last() end",
"def last?; end",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def previous_sibling=(other); end",
"def previous_sibling\n return @links[:previous_sibling]\n end",
"def last\n @children.last\n end",
"def last_sibling_index(parent)\n return -1 if groups.empty?\n\n if parent.nil?\n parent_index = 0\n sibling_level = 1\n else\n parent_index = groups.find_index(parent)\n sibling_level = parent.level + 1\n end\n\n raise \"Could not find group #{parent.name}\" if parent_index.nil?\n\n (parent_index..(header.groups_count - 1)).each do |i|\n break i unless groups[i].level == sibling_level\n end\n end",
"def get_last\n node = head\n until node.next.nil?\n node = node.next\n end\n return node.data\n end",
"def assert_last(string, last)\n Parser.parse(string)\n Parser.last.must_equal last\n end",
"def last\n self[-1]\n end",
"def at_bottom?\n lower_siblings.empty?\n end",
"def get_last\r\n return unless @head\r\n \r\n last = @head\r\n last = last.next until last.next.nil?\r\n last.data\r\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def last?\n index == size - 1\n end",
"def last?\n index == size - 1\n end",
"def last\n \tbegin\n \t raise ArgumentError, \"Empty LinkedList\" if @size <= 0\n \t return @last.prev.data\n \t rescue\n \t puts \"Empty\" \t\t \n\t\t end\n \tend",
"def last?\n self.index == (self.array.length - 1)\n end",
"def last\r\n self[-1]\r\n end",
"def assert_not_last_page\n assert_link NEXT_LABEL\n end",
"def last\n self[-1]\n end",
"def is_before_last?(elt)\n self[self.size - 2][:page].url == elt.url or self[self.size - 2][:driver].popup_name == elt.popup_name\n end",
"def is_last(target)\n index = @hash[target.name].index(target)\n last = @hash[target.name].size - 1\n return index == last\n end",
"def last\n node = @head;\n return node if node.next.nil?\n until (node.next.nil?) #until end of list\n node = node.next\n return node if node.next.nil?\n end\n end",
"def find_last &predicate\n return nil unless block_given? \n current = self.tail\n while current\n return current if predicate.call(current)\n current = current.prev\n end\nend",
"def move_to_bottom\n last_sib = last_sibling\n move_to_right_of(last_sib) if last_sib && self != last_sib\n end",
"def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend",
"def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end",
"def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end",
"def last; end",
"def last; end",
"def last; end",
"def last\n @ordered_elements.last\n end",
"def last_ele(class_name)\n ele_index class_name, 'last()'\n end",
"def last_ele(class_name)\n ele_index class_name, 'last()'\n end",
"def last\n end",
"def right_sibling\n base_class.first scoped(parent_column_name => _parent_id, left_column_name => { '$gt' => right }, :order => \"#{left_column_name}\")\n end",
"def add_last(e)\n node = Node.new(e, @sentinel.prev, @sentinel)\n @sentinel.prev.next = node\n @sentinel.prev = node\n end",
"def add_last(e)\n node = Node.new(e, @sentinel.prev, @sentinel)\n @sentinel.prev.next = node\n @sentinel.prev = node\n end",
"def is_last_segment_of_flight?\n return true if sibling_segments.empty?\n sibling_segments.sort_by {|segment| segment.index }.reverse.first == self\n end",
"def last\n node = @head\n while node && node.next\n node = node.next # i += 1\n end\n node\n end",
"def get_last\n current = head\n if head.nil?\n last_node = head\n else\n while !current.nil?\n last_node = current\n current = current.next\n end\n end\n return last_node.data\n end",
"def get_last\n return nil if @head == nil\n\n current_node = @head\n\n while current_node.next != nil\n current_node = current_node.next\n end\n\n return current_node.data\n end",
"def has_sibling?(peer)\n false\n end",
"def last_node\n return nil if @head.nil?\n current = @head\n while current.next != nil\n current = current.next\n end\n return current\n end",
"def next_is? &block\n last? ? nil : yield(element, self.next)\n end",
"def get_last\r\n return nil if !@head\r\n\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.next \r\n prev = curr\r\n curr = curr.next \r\n else \r\n return curr.data\r\n end\r\n end\r\n\r\n end",
"def get_last\n if length == 0\n return nil?\n elsif length == 1\n return @head.data\n else\n current = @head\n (length - 1).times do\n current = current.next\n end\n return current.data\n end\n end",
"def last\n @tail\n end",
"def next_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n s = sibs.index(id)\n TaxonName.find(sibs[ s + 1] ) if s < sibs.length - 1\n else\n nil\n end\n end",
"def last?\n position == bottom\n end",
"def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while current.next != nil \n current = current.next\n end\n return current.data\n end",
"def get_last\n return nil if !@head\n current = @head\n while current.next\n current = current.next\n end\n return current.data\n end",
"def last?\n index == @collection.length - 1\n end",
"def get_last\n return nil if @head.nil?\n return last_node.data\n end",
"def has_sibling?(peer); false end",
"def get_last\r\n # return nil if the linked list is empty\r\n if @head.nil?\r\n return nil\r\n end\r\n \r\n # otherwise, go to end of list ...\r\n current = @head\r\n until current.next.nil?\r\n # ... until 'current' is the last node ...\r\n current = current.next\r\n end\r\n \r\n # ... and return data from last node\r\n return current.data\r\n \r\n end",
"def last?\n # return false unless in_list?\n self.send(position_column) == bottom_position_in_list\n end",
"def next_sibling=(other); end",
"def get_last\n return nil if @head.nil?\n return get_last_helper(@head)\n end"
] |
[
"0.78397834",
"0.7777814",
"0.75926775",
"0.6686773",
"0.66590345",
"0.6619843",
"0.6617082",
"0.6594998",
"0.6557912",
"0.63980746",
"0.6383031",
"0.63199455",
"0.6260094",
"0.62564456",
"0.6239777",
"0.62381005",
"0.62360746",
"0.6223332",
"0.6221834",
"0.6216103",
"0.62147534",
"0.61397296",
"0.6107203",
"0.6095887",
"0.6094194",
"0.60685027",
"0.60673773",
"0.60567695",
"0.60486275",
"0.6033097",
"0.6030968",
"0.60106015",
"0.5996792",
"0.5966303",
"0.59599537",
"0.59599537",
"0.595208",
"0.5949842",
"0.5949842",
"0.5949488",
"0.59132373",
"0.5898023",
"0.58934534",
"0.5875677",
"0.58717185",
"0.58600634",
"0.58367807",
"0.5821484",
"0.5819707",
"0.5811438",
"0.58078724",
"0.5803325",
"0.5800065",
"0.5800065",
"0.5788803",
"0.5788803",
"0.5769676",
"0.5768038",
"0.5763185",
"0.57614356",
"0.57609266",
"0.57380134",
"0.57379997",
"0.5724933",
"0.57239765",
"0.57040256",
"0.57039535",
"0.5699771",
"0.5699771",
"0.5698342",
"0.5698342",
"0.5698342",
"0.5696782",
"0.56654054",
"0.56654054",
"0.5652197",
"0.56423545",
"0.5641395",
"0.5641395",
"0.563568",
"0.5633599",
"0.5628224",
"0.56225425",
"0.56211025",
"0.56090784",
"0.56067556",
"0.56002694",
"0.5591306",
"0.5580022",
"0.55775374",
"0.5569935",
"0.55658305",
"0.5563499",
"0.55634826",
"0.55608344",
"0.5559895",
"0.5555894",
"0.55553937",
"0.55537045",
"0.5549568"
] |
0.80057913
|
0
|
Test the siblings method, which is essentially an iterator.
|
def test_siblings
setup_test_tree
# Lets first collect the siblings in an array.
siblings = []
@child1.siblings { |sibling| siblings << sibling}
assert_equal(2, siblings.length, "Should have two siblings")
assert(siblings.include?(@child2), "Should have 2nd child as sibling")
assert(siblings.include?(@child3), "Should have 3rd child as sibling")
siblings.clear
siblings = @child1.siblings
assert_equal(2, siblings.length, "Should have two siblings")
siblings.clear
@child4.siblings {|sibling| siblings << sibling}
assert(siblings.empty?, "Should not have any siblings")
siblings.clear
siblings = @root.siblings
assert_equal(0, siblings.length, "Root should not have any siblings")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def inelastic_siblings\n siblings\n end",
"def ppl_many_siblings\n raise NotImplementedError\n end",
"def siblings\n without_self self_and_siblings\n end",
"def siblings\n self_and_siblings - [self]\n end",
"def siblings\n self_and_siblings - [self]\n end",
"def siblings\n self_and_siblings - [self]\n end",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def siblings\n without_self self_and_siblings\n end",
"def siblings\n self_and_siblings - [self]\n end",
"def siblings\n self_and_siblings - [self]\n end",
"def siblings\n self_and_siblings - [self]\n end",
"def siblings\n if not @sibs\n raise \"Prev not set for %s\" % self.line unless self.prev\n @sibs = StorylineLinks.where('from_id = ?', self.prev).select { |n| n.to_id != self.id }\n @sibs_num = @sibs.size\n end\n @sibs\n end",
"def sibling; end",
"def siblings\n parent && (parent.children - [self])\n end",
"def next_siblings(scope = {})\n self.class.find_in_nested_set(:all, \n { :conditions => [\"#{scope_condition} AND #{sibling_condition} AND #{self.class.table_name}.id != ? AND #{prefixed_left_col_name} > ?\", self.id, self[right_col_name]], :order => \"#{prefixed_left_col_name} ASC\"}, scope)\n end",
"def siblings\n without_self(self_and_siblings)\n end",
"def siblings\n parent&.children || []\n end",
"def siblings\n @siblings ||= Siblings.new(parent ? parent.children : [self])\n end",
"def siblings\n self_and_siblings.where(arel[:id].not_eq(id))\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def siblings\n pages = (p = parent and p.children)\n return Set.new unless pages\n return Set.new unless pages.include?(self)\n Set.new(pages)\n end",
"def siblings\n return [] unless parent\n parent.children.reject { |p| p == self }\n end",
"def siblings\n model_base_class.where(sibling_conditions)\n end",
"def siblings(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=? OR child_node_id=?', self.parent_node_id, self.child_node_id]}) do\n self.class.find(:all, *args) - [self]\n end\n end",
"def siblings\n model_base_class.scoped(:conditions => sibling_conditions)\n end",
"def siblings?(node1, node2)\n siblings(node1).include?(node2)\n end",
"def siblings\n self_and_siblings.where( table[tree.columns.id].not_eq(id) )\n end",
"def map_with_siblings\n raise 'Implement me'\n end",
"def ppl_siblings_in_file\n raise NotImplementedError\n end",
"def siblings\n tree_search_class.where({\n :_id => { \"$ne\" => self._id },\n tree_parent_id_field => self[tree_parent_id_field]\n }).sort(self.class.tree_sort_order()).all\n end",
"def next_sibling=(other); end",
"def siblings\n if self.parent.nil?\n self.class.where('forestify_level = 0').where('id != ?', self.id)\n else\n self.parent.children.where('forestify_level = ?', self.forestify_level).where('id != ?', self.id)\n end\n end",
"def map_with_siblings\n self.map.with_index { |_, index|\n yield(\n index > 0 ? self.at(index - 1) : nil,\n self[index],\n index < self.count() - 1 ? self[index + 1] : nil\n )\n }\n end",
"def get_siblings\n self.root? ? [] : self.siblings.select { |d| d.id != self.id }\n end",
"def siblings(scope = {})\n self_and_siblings(scope) - [self]\n end",
"def next_sibling\n return @links[:next_sibling]\n end",
"def siblings?(node_id, other_node_id)\n node_id ^ other_node_id == 1\n end",
"def siblings\n council.wards - [self]\n end",
"def siblings(reload = false)\n self_and_siblings(reload) - [self]\n end",
"def siblings(options = {})\n self.siblings_and_self(options).excludes(id: self.id)\n end",
"def siblings\n self.drill.exercises.sort\n end",
"def siblings(path)\n p_node = parent(path)\n p_node ? children(p_node.path) : []\n end",
"def subsequents(node)\n siblings[(position(node) + 1)..]\n end",
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def find_siblings(person)\n parent = find_parent(person)\n find_children(parent)\n .map(&:child)\n .map(&:name)\n .reject { |child| child == person }\n end",
"def shown_siblings\n siblings.reject(&:not_in_menu?)\n end",
"def subsequents\n siblings.subsequents(self)\n end",
"def siblings(n)\n # first find depth.\n depth = 0\n current = n\n while(n.parent)\n current = current.parent\n depth += 1\n end\n # edge case it's root\n if(depth == 0)\n return [current.value]\n end\n # go down to the right level and concat the nodes\n return [siblingshelper(current.left, depth-1)].concat([siblingshelper(current.right, depth-1)])\nend",
"def siblings\n teachable.media.where(sort: sort)\n end",
"def siblings_through(other, scope = {})\n self_and_siblings_through(other, scope) - [self]\n end",
"def self_and_siblings\n nested_set_scope.children_of parent_id\n end",
"def next_sibling\n # Raise error in case we are root\n raise RationalNumberIsRootNoSiblingsError if root?\n\n _parent = self.parent # Get parent already to avoid duplicate calculations\n _position = ((@nv - _parent.nv) / _parent.snv) + 1\n value_from_parent_and_position(_parent, _position)\n end",
"def sibling(name)\n parent && parent.find(name)\n end",
"def previous_sibling=(other); end",
"def right_siblings\n siblings.where( table[tree.columns.position].gteq(position) )\n end",
"def each_child\n \n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n assert_same(@child1, @child2.first_sibling, \"Child2's first sibling should be child1\")\n assert_same(@child1, @child3.first_sibling, \"Child3's first sibling should be child1\")\n assert_same(@child4, @child4.first_sibling, \"Child4's first sibling should be itself\")\n assert_not_same(@child1, @child4.first_sibling, \"Child4's first sibling is itself\")\n end",
"def siblings(*args)\n return call_ancestry_method(:siblings) if use_ancestry?\n\n Relationship.resources(sibling_rels(*args))\n end",
"def self_and_siblings\n parent ? parent.children : self.class.roots\n end",
"def self_and_siblings\n parent ? parent.children : self.class.roots\n end",
"def siblings\n # List other markdown files in the same folder.\n\n # Sibling folder.\n folder = File.dirname @absolute_path\n\n Slimdown::Folder.new(folder).pages\n end",
"def previous_siblings(scope = {})\n self.class.find_in_nested_set(:all, \n { :conditions => [\"#{scope_condition} AND #{sibling_condition} AND #{self.class.table_name}.id != ? AND #{prefixed_right_col_name} < ?\", self.id, self[left_col_name]], :order => \"#{prefixed_left_col_name} DESC\" }, scope)\n end",
"def traverse; end",
"def parse_sibling(scanner)\n parse(scanner)\n end",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def siblings(edge)\n out_edges(from(edge), edge.label)\n end",
"def siblings\n result = self_and_siblings - [self]\n result.delete_if { |sibling| !sibling.permitted? }\n result\n end",
"def self_and_siblings\n dataset.nested.filter(self.class.qualified_parent_column => self.parent_id)\n end",
"def siblings\n if top_level?\n Category.top_level\n else\n Category.joins(:parent_links)\n .where(category_hierarchies: {\n category1_id: parents\n })\n end\n end",
"def higher_siblings\n self.class.where(:position.lt => self.position)\n end",
"def self_and_siblings\n tree_search_class.where({\n tree_parent_id_field => self[tree_parent_id_field]\n }).sort(self.class.tree_sort_order()).all\n end",
"def calculated_siblings_position\n self.self_and_siblings.where('position < ?', self.position).count\n end",
"def self_and_siblings(scope = {})\n if self[parent_col_name].nil? || self[parent_col_name].zero?\n [self]\n else\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND #{sibling_condition}\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end\n end",
"def assert_next_sibling(id, expected_sibling_id)\n wait_for(:message => \"id '#{id}' should be next to '#{expected_sibling_id}'\") do\n actual_sibling_id = get_eval(\"this.page().findElement('#{id}').nextSibling.id\")\n expected_sibling_id == actual_sibling_id\n end\n end",
"def self_and_siblings\n #parent ? parent.children : self.class.roots\n self.class.find(:all, :conditions => {:parent_id => self.parent_id})\n end",
"def add_siblings_to(node, rpr_tag = T.unsafe(nil)); end",
"def siblings(node)\n return [] if root?(node)\n siblings = offsprings(parent(node))\n siblings.delete(node)\n siblings\n end",
"def each\n return enum_for(__method__) unless block_given?\n return if @head.nil?\n\n traverser = @head\n\n until traverser.nil?\n yield traverser\n traverser = traverser.next_node\n end\n end",
"def each\n return enum_for(__method__) unless block_given?\n return if @head.nil?\n\n traverser = @head\n\n until traverser.nil?\n yield traverser\n traverser = traverser.next_node\n end\n end",
"def left_sibling\n list.reverse.first(:position.lt => position)\n end",
"def sibling_of?(node)\n self.read_attribute(self.ancestry_base_class.ancestry_column) == node.read_attribute(self.ancestry_base_class.ancestry_column)\n end",
"def find_sibling_brothers(person)\n parent = find_parent(person)\n find_children(parent)\n .map(&:male_child)\n .compact\n .map(&:name)\n .reject { |child| child == person }\n end",
"def self_and_siblings\n parent ? parent.children : self.class.roots\n end",
"def self_and_siblings\n base_class.all scoped(parent_column_name => _parent_id)\n end",
"def self_and_siblings\n return [self] if self[nested_set_parent].nil? || self[nested_set_parent].zero?\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self[nested_set_parent]}\", :order => nested_set_left)\n end",
"def self_and_siblings\n if self[acts_as_nested_set_options[:parent_column]].nil? || self[acts_as_nested_set_options[:parent_column]].zero?\n [self]\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} and #{acts_as_nested_set_options[:parent_column]} = #{self[acts_as_nested_set_options[:parent_column]]}\", :order => acts_as_nested_set_options[:left_column])\n end\n end",
"def find_sibling_sisters(person)\n parent = find_parent(person)\n find_children(parent)\n .map(&:female_child)\n .compact\n .map(&:name)\n .reject { |child| child == person }\n end",
"def self_and_siblings\n ordered_tree_scope.where(parent_column => self[parent_column])\n end",
"def lower_siblings\n self.class.where(:position.gt => self.position)\n end",
"def left_siblings\n siblings.where( table[tree.columns.position].lteq(position) )\n end",
"def right_sibling\n list.first(:position.gt => position)\n end",
"def next_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n s = sibs.index(id)\n TaxonName.find(sibs[ s + 1] ) if s < sibs.length - 1\n else\n nil\n end\n end",
"def siblings\n others = user ? user.servers : Server.where(email: email, user_id: nil)\n others.where.not(id: id).to_a\n end",
"def each_child\n return nil unless self.child\n node = self.child\n while node\n yield node\n node = node.next_sibling\n end\n return true\n end",
"def has_sibling?(peer); false end",
"def pending_siblings_for(user)\n structural_parent.structural_children\n end",
"def has_siblings?\n tree_search_class.where(:_id => { \"$ne\" => self._id }) \\\n .where(tree_parent_id_field => self[tree_parent_id_field]) \\\n .sort(self.class.tree_sort_order()).count\n end",
"def next_sibling(num = 1, scope = {})\n scope[:limit] = num\n siblings = next_siblings(scope)\n num == 1 ? siblings.first : siblings\n end",
"def each(&prc)\n link = first\n until link == self.tail\n prc.call(link)\n link = link.next\n end\n\n end"
] |
[
"0.70834196",
"0.6983204",
"0.6980295",
"0.6934281",
"0.6934281",
"0.6934281",
"0.6865605",
"0.6863374",
"0.6852279",
"0.6826814",
"0.6826814",
"0.68249834",
"0.6802441",
"0.67338663",
"0.67019105",
"0.66974765",
"0.66627675",
"0.6584337",
"0.6557576",
"0.6557038",
"0.6531824",
"0.64339817",
"0.6433108",
"0.6424433",
"0.6412575",
"0.6406664",
"0.6398796",
"0.63515824",
"0.6338686",
"0.62900186",
"0.62642425",
"0.62536454",
"0.6252273",
"0.6235306",
"0.6199419",
"0.6176564",
"0.6164831",
"0.6159642",
"0.6156363",
"0.612829",
"0.6120884",
"0.6118079",
"0.6111046",
"0.6109793",
"0.6072845",
"0.59936064",
"0.5966847",
"0.5865466",
"0.5864587",
"0.58607674",
"0.5859864",
"0.5826161",
"0.5823991",
"0.5806174",
"0.5796126",
"0.5791127",
"0.5785191",
"0.5781736",
"0.57809436",
"0.5776765",
"0.5776765",
"0.5750349",
"0.57438725",
"0.57389253",
"0.57308817",
"0.5724065",
"0.5714242",
"0.5701269",
"0.56941944",
"0.56890064",
"0.5680476",
"0.5677766",
"0.56689006",
"0.5653013",
"0.56487083",
"0.5643795",
"0.56300944",
"0.56276",
"0.56135404",
"0.56135404",
"0.56121135",
"0.5603587",
"0.5573595",
"0.556799",
"0.55639213",
"0.5559558",
"0.5556581",
"0.55470675",
"0.5534995",
"0.5531972",
"0.5517231",
"0.5506543",
"0.54976696",
"0.5481736",
"0.5478339",
"0.5478305",
"0.54748374",
"0.5458165",
"0.5432483",
"0.5424353"
] |
0.7606843
|
0
|
Test the is_only_child? method.
|
def test_is_only_child_eh
setup_test_tree
assert( @root.is_only_child? , "Root is an only child")
assert(!@child1.is_only_child?, "Child1 is not the only child")
assert(!@child2.is_only_child?, "Child2 is not the only child")
assert(!@child3.is_only_child?, "Child3 is not the only child")
assert( @child4.is_only_child?, "Child4 is an only child")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_only_child?\n return false if parent.nil? # root\n 1 == parent.children.size\n end",
"def is_child?\n !is_parent?\n end",
"def child?\n false\n end",
"def child?\n true\n end",
"def is_only_child?\n return call_ancestry_method(:is_only_child?) if use_ancestry?\n\n relationships.all?(&:is_only_child?)\n end",
"def child_of?(parent); end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def child?\n !_parent_id.nil?\n end",
"def invalid_child?(child)\n false\n end",
"def invalid_child?(child)\n false\n end",
"def invalid_child?(child)\n false\n end",
"def has_child?\n !@children.empty?\n end",
"def has_children?\n false\n end",
"def children?\n !children.empty?\n end",
"def is_a_child?(object)\n object.respond_to?(:parent) && object.parent\n end",
"def have_children?\n children.count != 0\n end",
"def child_of?(parent)\n self.class.child?(type, parent)\n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n !self.children.empty?\n end",
"def valid_child(le)\n\t\t\treturn false\n\t\tend",
"def children?\n !children.empty?\n end",
"def children?\n !children.empty?\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def children_exist?\n\tend",
"def children?\n self.children.any?\n end",
"def child?\n parent_id = self[nested_set_parent]\n !(parent_id == 0 || parent_id.nil?) && (self[nested_set_left] > 1) && (self[nested_set_right] > self[nested_set_left])\n end",
"def child? \n parent_id = self[acts_as_nested_set_options[:parent_column]]\n !(parent_id == 0 || parent_id.nil?) && (self[acts_as_nested_set_options[:left_column]] > 1) && (self[acts_as_nested_set_options[:right_column]] > self[acts_as_nested_set_options[:left_column]])\n end",
"def children?\n return false if @children.length == 0\n end",
"def parent?\n !children.empty?\n end",
"def check_child?\n [\"AcademicClass\", \"Center\", \"CenterAdmin\", \"InstituteAdmin\", \"Institution\", \"Publisher\", \"Section\", \"StudentGroup\", \"Teacher\", \"CdnUser\", \"Moe\"].include? self.type\n end",
"def has_children?\n !children.empty?\n end",
"def children?\n !@children.empty?\n end",
"def is_childless?\n return call_ancestry_method(:is_childless?) if use_ancestry?\n\n relationships.all?(&:is_childless?)\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def has_childs\n access = Access.where(:parent_id=>id).first\n if access.blank?\n return false\n else\n return true\n end\n end",
"def child_condition; end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def hasChild?\n @path.size > 1\n end",
"def has_children?\n children.any?\n end",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def has_children?\n !leaf?\n end",
"def parentable?\n false\n end",
"def has_children?\n\t return true unless self.child_a.nil? || self.child_b.nil? \n\tend",
"def parent_has_constraints_on_children?\n parent_tag[:definition][:only_allow] != nil\n end",
"def children\n child_check\n super\n end",
"def children?\n\t\t\t@children.size > 0 ? true : false\n\t\tend",
"def has_child(name)\n @hasChild = name\n end",
"def children?\n\t\t\t@children && !@children.empty?\n\t\tend",
"def is_child_of?(_parent)\n return false if (self == _parent) or self.root?\n _parent == self.parent\n end",
"def children?\n\t\t\treturn children.size > 0\n\t\tend",
"def has_children?\n @children.length > 0\n end",
"def parent?\n false\n end",
"def has_child?(childPath)\n `#@native.hasChild(childPath)`\n end",
"def has_children?\n ( self[:has_children] == 1 )\n end",
"def preserve_children?\n false\n end",
"def can_chain_child?\n self.chain_select_child.to_s != ''\n end",
"def children?\n return false if ((self.children == nil) || (self.children == []))\n return true\n end",
"def hasChildren?\n children = getChildren\n return false if children.empty? or children.nil?\n return true\n end",
"def parent?\n true \n end",
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def has_children()\n return 1 if(@children.length > 0)\n 0\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def parent?\n false\n end",
"def has_parent?\n !parent.nil?\n end",
"def nested_child?\n @elements.last.class.method_defined?('add_element') && @elements.last.container\n end",
"def focusable?\n @children.any?\n end",
"def child?\n @child_pid.nil?\n end",
"def child? \n parent_id = self[parent_col_name]\n !(parent_id == 0 || parent_id.nil?) && (self[left_col_name] > 1) && (self[right_col_name] > self[left_col_name])\n end",
"def child? \n parent_id = self[parent_col_name]\n !(parent_id == 0 || parent_id.nil?) && (self[left_col_name] > 1) && (self[right_col_name] > self[left_col_name])\n end",
"def children?\n @contents.children?\n end",
"def parent?\n true\n end",
"def show_in_child_list?\n\t\t\ttrue\n\t\tend",
"def child_of?(category, options = {})\n category.children.exists?(id)\n end",
"def leaf?\n self.children.size == 0\n end",
"def has_parent?\n !root?\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def has_children?\n @nodes && !@nodes.empty?\n end",
"def valid_children\n allowed_children_and_descendants.select {|child| child.allowed_parent?(self)}\n end"
] |
[
"0.8115992",
"0.80901664",
"0.8003854",
"0.7896261",
"0.788674",
"0.7732107",
"0.7650381",
"0.7649291",
"0.7649291",
"0.7621647",
"0.74487025",
"0.741235",
"0.741235",
"0.741235",
"0.7374786",
"0.7319415",
"0.72612846",
"0.71617126",
"0.71441275",
"0.7141895",
"0.7136186",
"0.7136186",
"0.7136186",
"0.7136186",
"0.7120659",
"0.7120659",
"0.7111665",
"0.71019703",
"0.7099153",
"0.7099153",
"0.70774466",
"0.70774466",
"0.70774466",
"0.70774466",
"0.70318866",
"0.701656",
"0.7001198",
"0.6985584",
"0.6971294",
"0.69672686",
"0.6966208",
"0.6959736",
"0.69527423",
"0.6930421",
"0.69302416",
"0.69302416",
"0.6924656",
"0.6921224",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6914567",
"0.6897592",
"0.6877815",
"0.6872018",
"0.68650454",
"0.6862159",
"0.6861075",
"0.684196",
"0.6802947",
"0.6796303",
"0.679315",
"0.6768361",
"0.67588925",
"0.67340934",
"0.67168665",
"0.6689905",
"0.6670384",
"0.66595924",
"0.6636442",
"0.6597162",
"0.65896964",
"0.6548767",
"0.65341467",
"0.65266615",
"0.6514722",
"0.6506975",
"0.6506975",
"0.6506975",
"0.65004385",
"0.6488794",
"0.6467703",
"0.6465649",
"0.6463708",
"0.64610106",
"0.64610106",
"0.64602566",
"0.6443629",
"0.6438108",
"0.6422209",
"0.6416599",
"0.6413547",
"0.6392471",
"0.6378649",
"0.6378254"
] |
0.8213884
|
0
|
Test the next_sibling method.
|
def test_next_sibling
setup_test_tree
assert_nil(@root.next_sibling, "Root does not have any next sibling")
assert_equal(@child2, @child1.next_sibling, "Child1's next sibling is Child2")
assert_equal(@child3, @child2.next_sibling, "Child2's next sibling is Child3")
assert_nil(@child3.next_sibling, "Child3 does not have a next sibling")
assert_nil(@child4.next_sibling, "Child4 does not have a next sibling")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def next_sibling\n return @links[:next_sibling]\n end",
"def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend",
"def next_sibling=(other); end",
"def assert_next_sibling(id, expected_sibling_id)\n wait_for(:message => \"id '#{id}' should be next to '#{expected_sibling_id}'\") do\n actual_sibling_id = get_eval(\"this.page().findElement('#{id}').nextSibling.id\")\n expected_sibling_id == actual_sibling_id\n end\n end",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def add_next_sibling(node_or_tags); end",
"def sibling; end",
"def next_sibling\n # Raise error in case we are root\n raise RationalNumberIsRootNoSiblingsError if root?\n\n _parent = self.parent # Get parent already to avoid duplicate calculations\n _position = ((@nv - _parent.nv) / _parent.snv) + 1\n value_from_parent_and_position(_parent, _position)\n end",
"def next\n DOM::Element.from_node `#{@el}.nextElementSibling || Opal.nil`\n end",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def parse_sibling(scanner)\n parse(scanner)\n end",
"def previous_sibling=(other); end",
"def has_next()\n \n end",
"def has_next()\n \n end",
"def next_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n s = sibs.index(id)\n TaxonName.find(sibs[ s + 1] ) if s < sibs.length - 1\n else\n nil\n end\n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def next\n value = `#{@el}.nextElementSibling || false`\n value ? DOM::Element.fromNode(value) : nil\n end",
"def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n assert_same(@child1, @child2.first_sibling, \"Child2's first sibling should be child1\")\n assert_same(@child1, @child3.first_sibling, \"Child3's first sibling should be child1\")\n assert_same(@child4, @child4.first_sibling, \"Child4's first sibling should be itself\")\n assert_not_same(@child1, @child4.first_sibling, \"Child4's first sibling is itself\")\n end",
"def has_next\n return !(self.next_node.nil?)\n end",
"def is_or_is_sibling_of?(other)\n (other == self) or is_sibling_of?(other)\n end",
"def next_element_sibling\n n = self.next_sibling\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end",
"def has_next\n\t\tend",
"def validate_sibling!(other)\n unless other.is_a?(tree.base_class)\n message = \"#{tree.base_class.name} expected, got #{other.class.name}\"\n raise ActiveRecord::AssociationTypeMismatch, message\n end\n\n other.ordered_tree_node\n end",
"def test_next\n \t@sequence.next\n \tassert_equal(@sequence.current, 5)\n \t@sequence.next\n \tassert_equal(@sequence.current, 8)\n @sequence.next\n assert_equal(@sequence.current, 13)\n end",
"def has_next?; end",
"def add_previous_sibling(node_or_tags); end",
"def has_sibling?(peer)\n false\n end",
"def next_is? &block\n last? ? nil : yield(element, self.next)\n end",
"def calculable_sibling?(edge, sibling)\n sibling == edge || sibling.demand\n end",
"def previous_sibling\n return @links[:previous_sibling]\n end",
"def next\n @next && @next.value\n end",
"def is_sibling_of?(other)\n (other != self) and (other[tree_parent_id_field] == self[tree_parent_id_field])\n end",
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"def right_sibling\n right_siblings.first\n end",
"def has_sibling?(peer); false end",
"def has_next?()\n if @next_node\n return true\n else\n return false\n end\n end",
"def next_node_is_text?(node)\n !node.next_sibling.nil? && node.next_sibling.text? && !node.next_sibling.text.strip.empty?\n end",
"def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend",
"def get_next()\n return @next_node\n end",
"def next_node\n children.first || successor\n end",
"def sibling_of?(node)\n self.read_attribute(self.ancestry_base_class.ancestry_column) == node.read_attribute(self.ancestry_base_class.ancestry_column)\n end",
"def next_element\n validates_possibility_of :next\n self.index += 1\n self.current\n end",
"def next?\n not self.next.nil?\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def sibling(name)\n parent && parent.find(name)\n end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def next_sibling(num = 1, scope = {})\n scope[:limit] = num\n siblings = next_siblings(scope)\n num == 1 ? siblings.first : siblings\n end",
"def next_element; end",
"def test_next\n\t\tassert_equal(6, @freeid.next, \"Extras not working\")\n\t\tassert_equal(1, @freeid.next, \"Last not working\")\n\t\tassert_equal(2, @freeid.next, \"Last not incrementing\")\n\tend",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def test_next_one_neighbor\r\n\t\t@t.add_neighbor @t2\r\n\t\tassert_equal @t2, @t.next\r\n\tend",
"def test_next_node\n list = LinkedList.new\n assert_equal nil, list.next_node\n end",
"def add_sibling(other)\n if self.next_sibling\n old_sibling = self.next_sibling\n old_sibling.link(:previous_sibling, other)\n other.link(:next_sibling, old_sibling)\n end\n self.link(:next_sibling, other)\n other.link(:previous_sibling, self)\n end",
"def next?\n self.rel == \"next\"\n end",
"def next?\n raise NotImplementedError\n end",
"def next?\n raise NotImplementedError\n end",
"def has_sibling?(peer)\n\t plan.has_sibling?(peer)\n\tend",
"def right_sibling\n list.first(:position.gt => position)\n end",
"def next_node\n @SuccessorReference.value\n end",
"def next_siblings(scope = {})\n self.class.find_in_nested_set(:all, \n { :conditions => [\"#{scope_condition} AND #{sibling_condition} AND #{self.class.table_name}.id != ? AND #{prefixed_left_col_name} > ?\", self.id, self[right_col_name]], :order => \"#{prefixed_left_col_name} ASC\"}, scope)\n end",
"def assignSiblingNode(sibling)\n\t\t@siblingNode = sibling \n\tend",
"def has_next?\n !self.last?\n end",
"def left_sibling\n higher_items.last\n end",
"def test_current\n \t@sequence.next\n \tassert_equal(@sequence.current, 5)\n @sequence.next\n assert_equal(@sequence.current, 8)\n @sequence.reset\n assert_equal(@sequence.current, nil)\n end",
"def next_sibling_by_date\n siblings_by_date.where(\"starts_at >= ?\", starts_at)&.first\n end",
"def test_node_can_take_in_data_and_next_node_data\n node = Node.new(\"pizza\", \"link\" )\n assert_equal \"pizza\", node.data\n assert_equal \"link\", node.next_node\n end",
"def next_element\n\t\treturn next_element_of @current_node\n\tend",
"def next\n @next||=after.first\n end",
"def next_node(html_node)\n # Hack to prevent reading empty text nodes\n next_node = html_node.next\n is_empty = ( !next_node.nil? ) && next_node.text? && next_node.text.gsub(/[\\r\\n\\s]/, '').empty?\n while is_empty\n next_node = next_node.next\n is_empty = ( !next_node.nil? ) && next_node.text? && next_node.text.gsub(/[\\r\\n\\s]/, '').empty?\n end\n next_node\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_sibling, \"Child2's last sibling should be child3\")\n assert_same(@child3, @child3.last_sibling, \"Child3's last sibling should be itself\")\n assert_same(@child4, @child4.last_sibling, \"Child4's last sibling should be itself\")\n assert_not_same(@child3, @child4.last_sibling, \"Child4's last sibling is itself\")\n end",
"def next\n @next\n end",
"def next?(other)\n return self.next_rank == other \n end",
"def has_next?\n !!@links['next']\n end",
"def expect_next(one, two = nil)\n tok = next_token\n check_eq tok, one, two\n end",
"def each_child\n return nil unless self.child\n node = self.child\n while node\n yield node\n node = node.next_sibling\n end\n return true\n end",
"def next_node(example)\n if example[@feature] <= @value || (example[@feature] - @value).abs < EPSI\n self.left\n else\n self.right\n end\n end",
"def next() end",
"def next() end",
"def test_next_no_neighbors\r\n\t\tassert_nil @t.next\r\n\tend",
"def left_sibling\n list.reverse.first(:position.lt => position)\n end",
"def first_sibling\n node = self\n while node.previous_sibling\n node = node.previous_sibling\n end\n return node\n end",
"def last?\n !right_sibling\n end",
"def next_node(example)\n if example[@feature].to_s == @value\n self.left\n else\n self.right\n end\n end",
"def previous_node_is_text?(node)\n !node.previous_sibling.nil? && node.previous_sibling.text? && !node.previous_sibling.text.strip.empty?\n end",
"def on_next?\n @kind == :on_next\n end",
"def next\n after.first\n end",
"def next?\n !@continuation.nil?\n end",
"def next\n next? ? @current + 1 : nil\n end",
"def preceding(node); end",
"def line_break_has_no_previous_sibling?(node)\n node.name == 'br' && node.previous_sibling.nil? &&\n node.ancestors.all? { |ancestor| ancestor.previous_sibling.nil? }\n end",
"def next()\n result = current\n @index += 1\n @got_next_element = false\n @next_element = nil\n result\n end",
"def test_current_idx\n \t@sequence.next\n \tassert_equal(@sequence.current_idx, 0)\n @sequence.next\n assert_equal(@sequence.current_idx, 1)\n end",
"def find_subsequent()\n curr = self\n while !curr.next.nil?\n curr = curr.next \n return curr if yield curr\n end\n\n return nil\n end",
"def move_next\n\t\tself.current = self.current&.next\n\tend",
"def move_next\n\t\tself.current = self.current&.next\n\tend",
"def get_next()\n\t\t\treturn @next\n\t\tend",
"def insert_after(sibling)\n CMark.node_insert_before(@pointer, sibling.pointer)\n if res == 0 then raise NodeError, \"could not insert after\" end\n end"
] |
[
"0.76542443",
"0.76073545",
"0.7462824",
"0.7378023",
"0.7237333",
"0.71161175",
"0.70956135",
"0.67643636",
"0.6759868",
"0.6719854",
"0.66626745",
"0.6623448",
"0.654384",
"0.65373915",
"0.64451945",
"0.64451945",
"0.6405785",
"0.63927156",
"0.63911545",
"0.6361223",
"0.6304422",
"0.62972355",
"0.62908554",
"0.6275172",
"0.6256114",
"0.62107676",
"0.620402",
"0.61969805",
"0.61826146",
"0.61768657",
"0.61501944",
"0.61293054",
"0.6123014",
"0.60918534",
"0.6063461",
"0.6058865",
"0.6053023",
"0.6030395",
"0.5980205",
"0.59791243",
"0.5947787",
"0.59298235",
"0.5918179",
"0.59141165",
"0.59080637",
"0.589292",
"0.5887525",
"0.58454555",
"0.58359474",
"0.58272785",
"0.5819754",
"0.58186203",
"0.5818606",
"0.58079547",
"0.5800043",
"0.5795624",
"0.578659",
"0.578659",
"0.57786363",
"0.5764566",
"0.5750334",
"0.5746021",
"0.5739074",
"0.5729899",
"0.5710396",
"0.570309",
"0.56951743",
"0.5689836",
"0.56897",
"0.56861293",
"0.5684672",
"0.5667059",
"0.56420827",
"0.5614571",
"0.5602202",
"0.5594163",
"0.5549338",
"0.55291903",
"0.55289567",
"0.5519895",
"0.5519895",
"0.55158603",
"0.55124253",
"0.5511584",
"0.55105513",
"0.55032414",
"0.55009747",
"0.54958576",
"0.5487207",
"0.5481165",
"0.54681426",
"0.5454532",
"0.5454201",
"0.54541194",
"0.5440029",
"0.5438065",
"0.54378253",
"0.54378253",
"0.54377896",
"0.5431873"
] |
0.7859511
|
0
|
Test the previous_sibling method.
|
def test_previous_sibling
setup_test_tree
assert_nil(@root.previous_sibling, "Root does not have any previous sibling")
assert_nil(@child1.previous_sibling, "Child1 does not have previous sibling")
assert_equal(@child1, @child2.previous_sibling, "Child2's previous sibling is Child1")
assert_equal(@child2, @child3.previous_sibling, "Child3's previous sibling is Child2")
assert_nil(@child4.previous_sibling, "Child4 does not have a previous sibling")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def previous_sibling\n return @links[:previous_sibling]\n end",
"def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend",
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"def previous_sibling=(other); end",
"def previous_sibling\n return nil if parent.nil? # self is root\n return nil if 1 == parent.children.size # self is parent's only child\n if 0 == own_child_index\n return nil # self is first child\n else\n # return previous sibling\n parent.children[own_child_index - 1]\n end\n end",
"def previous_element_sibling\n n = self.previous_sibling\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.previous_sibling\n end\n return n\n end",
"def previous\n DOM::Element.from_node `#{@el}.previousElementSibling || Opal.nil`\n end",
"def add_previous_sibling(node_or_tags); end",
"def previous_is? &block\n first? ? nil : yield(element, self.previous)\n end",
"def has_prev?()\n if @prev_node\n return true\n else\n return false\n end\n end",
"def previous?\n self.rel == \"previous\"\n end",
"def previous_element; end",
"def get_prev()\n return @prev_node\n end",
"def previous_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n\n s = sibs.index(id)\n TaxonName.find(sibs[s - 1]) if s != 0\n else\n nil\n end\n end",
"def add_previous_sibling_and_get(node, html)\n\t\tresult = node.add_previous_sibling(make_node(html, node.document))\n\t\tresult = result[0] if result.is_a?(Array)\n\t\treturn result\n\tend",
"def prev_element_of(node)\n\t\treturn valid(node) ? node.previous_element : nil\n\tend",
"def previous_sibling(num = 1, scope = {})\n scope[:limit] = num\n siblings = previous_siblings(scope)\n num == 1 ? siblings.first : siblings\n end",
"def prev?\n not prev.nil?\n end",
"def prev_element\n\t\treturn prev_element_of @current_node\n\tend",
"def previous_node_is_text?(node)\n !node.previous_sibling.nil? && node.previous_sibling.text? && !node.previous_sibling.text.strip.empty?\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def TreeView_GetPrevSibling(hwnd, hitem) TreeView_GetNextItem(hwnd, hitem, TreeViewGetNextItem[:PREVIOUS]) end",
"def previous_siblings(scope = {})\n self.class.find_in_nested_set(:all, \n { :conditions => [\"#{scope_condition} AND #{sibling_condition} AND #{self.class.table_name}.id != ? AND #{prefixed_right_col_name} < ?\", self.id, self[left_col_name]], :order => \"#{prefixed_left_col_name} DESC\" }, scope)\n end",
"def next_sibling\n return @links[:next_sibling]\n end",
"def previous_sibling_by_date\n siblings_by_date.where(\"starts_at < ?\", starts_at)&.last\n end",
"def predecessor\n siblings.previous(self) || parent\n end",
"def previous?(other)\n return self.previous_rank == other \n end",
"def previous\n end",
"def previous\n end",
"def previous\n\t first? ? nil : locate - 1\n\tend",
"def sibling; end",
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end",
"def prev\n\t\t@prev\n\tend",
"def prev\n prev? ? @current - 1 : nil\n end",
"def prev\n perform_get(links.prev, self.class)\n end",
"def previous\n validates_possibility_of :previous\n self.index -= 1\n self.current\n end",
"def next_sibling=(other); end",
"def test_next_prev\n # list parent\n i1 = C::Int.new\n i2 = C::Int.new\n list = Chain[i1, i2]\n assert_same(i2, i1.next)\n assert_nil(i2.next)\n assert_same(i1, i2.prev)\n assert_nil(i1.prev)\n\n # node parent\n i1 = C::IntLiteral.new(1)\n i2 = C::IntLiteral.new(2)\n a = C::Add.new(i1, i2)\n assert_same(i2, i1.next)\n assert_nil(i2.next)\n assert_same(i1, i2.prev)\n assert_nil(i1.prev)\n\n # no parent\n i = C::Int.new\n assert_raises(C::Node::NoParent){i.next}\n assert_raises(C::Node::NoParent){i.prev}\n end",
"def has_previous_page\n @agent.page.links.find { |l| l.text == \"← Previous\" } == nil ? false : true\n end",
"def previous_step\n self.step_flow.previous_step if can_decrement_step\n end",
"def set_prev(node)\n\t\t\t@prev = node\n\t\tend",
"def preceding(node); end",
"def get_prev()\n\t\t\treturn @prev\n\t\tend",
"def visit_prev_page(model, **opt)\n click_on PREV_LABEL, match: :first\n if block_given?\n yield\n else\n show_url\n end\n assert_valid_index_page(model, **opt)\n end",
"def left_sibling\n higher_items.last\n end",
"def assert_next_sibling(id, expected_sibling_id)\n wait_for(:message => \"id '#{id}' should be next to '#{expected_sibling_id}'\") do\n actual_sibling_id = get_eval(\"this.page().findElement('#{id}').nextSibling.id\")\n expected_sibling_id == actual_sibling_id\n end\n end",
"def prev(name = nil)\n elements = self.class.all_siblings(self)\n elements = elements.where(:name => name) if name\n elements.where(\"position < ?\", self.position).order(\"position ASC\").limit(1)\n end",
"def prev(name = nil)\n previous_or_next('<', name)\n end",
"def add_previous_sibling(node_or_tags)\n raise ArgumentError.new(\"A document may not have multiple root nodes.\") if (parent && parent.document?) && !(node_or_tags.comment? || node_or_tags.processing_instruction?)\n\n add_sibling :previous, node_or_tags\n end",
"def previous=(node_or_tags); end",
"def previous_segment\n return nil if sibling_segments.empty?\n index = sibling_segments.sort_by(&:index).index(self)\n if index && index >= 1\n sibling_segments[index - 1]\n else\n nil\n end\n end",
"def left_sibling\n list.reverse.first(:position.lt => position)\n end",
"def prev?\n current_page > 1\n end",
"def move_lower\n next_sib = next_sibling\n move_to_right_of(next_sib) if next_sib\n end",
"def set_prev(node)\n @prev_node = node\n end",
"def is_sibling_of?(other)\n (other != self) and (other[tree_parent_id_field] == self[tree_parent_id_field])\n end",
"def previous?\n return @page > 1\n end",
"def previous_node\n peer = nil\n if !parent.nil? and parent.respond_to?(:children)\n index = parent.children.index(self)\n peer = index > 0 ? parent.children[index - 1] : nil\n end\n peer\n end",
"def previous_differs_on? field\n if first?\n nil\n else\n element.send(field) != previous.send(field)\n end\n end",
"def previous\n before.ascending.last\n end",
"def assert_not_first_page\n assert_link PREV_LABEL\n end",
"def intend_previous\n intend_with :last, :previous\n end",
"def intend_previous\n intend_with :last, :previous\n end",
"def has_previous\n @pictures.previous?\n end",
"def prev\n\t\tself - 1\n\tend",
"def find_prev(*args)\n find(:prev, *args)\n end",
"def find_prev(*args)\n find(:prev, *args)\n end",
"def previous?\n previous_id != '0'\n end",
"def has_sibling?(peer)\n false\n end",
"def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n assert_same(@child1, @child2.first_sibling, \"Child2's first sibling should be child1\")\n assert_same(@child1, @child3.first_sibling, \"Child3's first sibling should be child1\")\n assert_same(@child4, @child4.first_sibling, \"Child4's first sibling should be itself\")\n assert_not_same(@child1, @child4.first_sibling, \"Child4's first sibling is itself\")\n end",
"def goto_prev\n pointer, matching_pointers = @itr_pointer.next(@builder['skip_matched_checkbutton'].active?, false)\n if (pointer == nil)\n @itr_pointer.reset\n pointer, matching_pointers = @itr_pointer.next(@builder['skip_matched_checkbutton'].active?, false)\n if (pointer == nil)\n notify('No more items to compare')\n else\n notify('Cycling items to compare from the end')\n end\n else\n @idx_comparison -= 1\n notify('')\n end\n load_comparison(pointer, matching_pointers)\n end",
"def validate_sibling!(other)\n unless other.is_a?(tree.base_class)\n message = \"#{tree.base_class.name} expected, got #{other.class.name}\"\n raise ActiveRecord::AssociationTypeMismatch, message\n end\n\n other.ordered_tree_node\n end",
"def line_break_has_no_previous_sibling?(node)\n node.name == 'br' && node.previous_sibling.nil? &&\n node.ancestors.all? { |ancestor| ancestor.previous_sibling.nil? }\n end",
"def previous(node)\n priors(node).last\n end",
"def search_for_ previous_element(_start_element, _style)\n unless _start_element.nil?\n # have we already found what we're looking for?\n if _start_element.name == _style\n return _start_element\n end\n # _start_element is a div.block and not the _start_element itself\n if _start_element[:class] == \"block\" && _start_element[:id] != @start_here[:id]\n # begin recursion with last child inside div.block\n from_child = search_for_ previous_element(_start_element.children.last, _style)\n if(from_child)\n return from_child\n end\n end\n # begin recursion with previous element\n from_child = search_for_ previous_element(_start_element.previous, _style) \n return from_child ? from_child : false\n else\n return false\n end\nend",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend",
"def calculate_prev\n p = @current_page - 1\n p <= 0 || p > @total_pages ? nil : p\n end",
"def previous\n @pointer -= 1\n end",
"def previous_node\n return nil if @traversal_position.previousNode.nil?\n Neo4j.load(@traversal_position.previousNode.getId)\n end",
"def previous\n first? ? nil : @collection[index - 1]\n end",
"def prev\n perform_request(prev_page_uri) if prev_page_uri\n end",
"def prev_page?\n page_number > first_page_number\n end",
"def previous?\n (previous.nil? || previous.lines.empty?) ? false : true\n end",
"def next_sibling\n # Raise error in case we are root\n raise RationalNumberIsRootNoSiblingsError if root?\n\n _parent = self.parent # Get parent already to avoid duplicate calculations\n _position = ((@nv - _parent.nv) / _parent.snv) + 1\n value_from_parent_and_position(_parent, _position)\n end",
"def previous_page\n @current_page = @agent.page.links.find { |l| l.text == \"← Previous\" }.click\n rescue\n nil\n end",
"def previous_page?\n !previous_page_link.nil?\n end",
"def previous_page!\n previous_page.tap { |page| update_self(page) }\n end",
"def has_sibling?(peer); false end",
"def previous_page?\n page > 1\n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def previous_page\n return if page == 1\n page - 1\n end",
"def get_previous_node(item)\n raise ArgumentError, 'Previous node does not exist' if @length < 2\n\n previous_node = @front_node\n\n until previous_node.next_node.nil? || previous_node.next_node.item == item\n previous_node = previous_node.next_node\n end\n\n unless previous_node.next_node.item == item\n raise ArgumentError, 'Item is not present'\n end\n\n previous_node\n end",
"def previous\n\t\t@result = nil\n\t\t@skip = (@skip || 0) - get_resultcount\n\t\t@skip = [0, @skip].max\n\t\treturn self\n\tend",
"def prev(current)\n l = current\n l = l[0,1] if (l.length > 0 and l[0,1] == '\\n')\n l = l[-1,1] if (l.length > 0 and l[-1,1] == '\\n')\n if (@position > 0)\n if (@position == (@history.length - 1))\n @history[@history.length - 1] = l\n end\n @position = @position - 1\n return @history[@position]\n end\n return current\n end",
"def prev\n @prev ||= node_cache.fetch(prev_uri) if prev_uri\n end",
"def select_prev_question\n prev = find_prev_next_question[0]\n self.current_question = prev if prev\n end",
"def store_previous\n end",
"def previous_node_name(node)\n previous_node = node.previous_sibling\n while !previous_node.nil?\n break if previous_node.element?\n\n previous_node = previous_node.previous_sibling\n end\n\n previous_node&.name&.downcase if previous_node&.element?\n end"
] |
[
"0.7949191",
"0.78544027",
"0.77540195",
"0.7651189",
"0.7334865",
"0.73188716",
"0.7155193",
"0.70268035",
"0.7015421",
"0.7009322",
"0.6913326",
"0.6905757",
"0.690292",
"0.6900668",
"0.6895148",
"0.6839489",
"0.6709548",
"0.6701049",
"0.6685996",
"0.6659306",
"0.66137254",
"0.65807337",
"0.6511631",
"0.6504365",
"0.6498892",
"0.64669305",
"0.64641446",
"0.64512885",
"0.64512885",
"0.6449582",
"0.644318",
"0.64370257",
"0.64302146",
"0.64228964",
"0.6388272",
"0.6385464",
"0.6332128",
"0.6319386",
"0.6318256",
"0.6274874",
"0.62706584",
"0.6261631",
"0.6236523",
"0.6232283",
"0.6205304",
"0.61844665",
"0.61815834",
"0.61681527",
"0.6164723",
"0.61620444",
"0.61527574",
"0.6142306",
"0.613806",
"0.61372787",
"0.61065036",
"0.6099426",
"0.6097494",
"0.6078008",
"0.6053774",
"0.60499346",
"0.6048751",
"0.6036459",
"0.6023499",
"0.6023499",
"0.6018563",
"0.6002056",
"0.5993014",
"0.5993014",
"0.59868747",
"0.59612334",
"0.5947206",
"0.59317696",
"0.5930377",
"0.59246224",
"0.5924218",
"0.5917842",
"0.5915236",
"0.59037167",
"0.5881161",
"0.58769256",
"0.5871415",
"0.58574456",
"0.5857249",
"0.5853606",
"0.58534795",
"0.5847095",
"0.5843156",
"0.5841769",
"0.5834886",
"0.5830314",
"0.5828104",
"0.58220965",
"0.5796399",
"0.5794249",
"0.5790993",
"0.57865125",
"0.5776291",
"0.5770699",
"0.5765561",
"0.57653874"
] |
0.82296556
|
0
|
Test the add method.
|
def test_add
assert(!@root.has_children?, "Should not have any children")
assert_equal(1, @root.size, "Should have 1 node (the root)")
@root.add(@child1)
@root << @child2
assert(@root.has_children?, "Should have children")
assert_equal(3, @root.size, "Should have three nodes")
@root << @child3 << @child4
assert_equal(5, @root.size, "Should have five nodes")
assert_equal(2, @child3.size, "Should have two nodes")
# Test the addition of a duplicate node (duplicate being defined as a node with the same name).
assert_raise(RuntimeError) { @root.add(Tree::TreeNode.new(@child1.name)) }
# Test the addition of a nil node.
assert_raise(ArgumentError) { @root.add(nil) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add \n end",
"def add\n end",
"def add\n end",
"def add\n\tend",
"def test_add\n\t\tassert_raise( RuntimeError ) { @freeid.add(\"Yo\") }\n\t\t@freeid.next\n\t\t@freeid.next\n\t\t@freeid.add(6)\n\t\tassert_equal(6, @freeid.next, \"Add not working\")\n\t\tassert_equal(2, @freeid.next, \"Last not working after add\")\n\tend",
"def add\n\nend",
"def test_match\n assert_equal(2, add(1,1))\n end",
"def test_add_alias\n new_todo = Todo.new('new todo')\n @list.add(new_todo)\n @todos << new_todo\n\n assert_equal(@todos, @list.to_a)\n end",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def add(value)\n end",
"def test_append_method\n list = LinkedList.new\n\n list.append(\"West\", {\"pounds of food\" => 200})\n\n assert_instance_of Node, list.head\n assert_equal \"West\", list.head.surname\n end",
"def add(*args); end",
"def add(value)\n\tend",
"def add(o); addObject o end",
"def test_add_to_bag\r\n \t@test_prospector.current_gold = 2\r\n \t@test_prospector.current_silver = 3\r\n \t@test_prospector.add_to_bag\r\n \tassert_equal 3, @test_prospector.total_silver\r\n \tassert_equal 2, @test_prospector.total_gold\r\n end",
"def test_add\n q = Queue.new\n q.add(1)\n assert_equal(1, q.queue.head.data)\n assert_equal(1, q.size)\n assert_equal(q.queue.tail, q.queue.head)\n end",
"def add(*); end",
"def test_add_book\n\t\tassert_equal 1, @new_driver.book(1)\n\tend",
"def add(*args, &block)\n\n end",
"def test_add_new_book\n library_plus_new_book = @compiled_library.add_new_book(\"Nineteen Eighty Four\")\n assert_equal(@compiled_library.books, library_plus_new_book)\n end",
"def test_for_add_guest\n assert_equal(0,@venue.guests.length)#assert 0 guests\n @venue.add_guest(@gina)#push /shovel guest\n assert_equal(1,@venue.guests.length)#check guest list increased\n end",
"def test_add_1food\n\t\tputs \"TEST 2\"\n\t\tassert( @db.empty?, \"DB should be empty\" )\n\t\t@db.addFood(\"Potato\", \"123\")\n\t\tassert( @db.size == 1, \"Size of DB != 1\")\n\t\tassert( !@db.empty?, \"DB should not be empty\")\n\tend",
"def test_linked_list_append\n list = LinkedList.new\n new_node = list.append(\"Rhodes\", {\"pounds of food\" => 200})\n assert_equal \"Rhodes\", new_node.surname\n assert_equal Node, new_node.class\n end",
"def test_add_friend__works\n result = add_friend(@person1, \"George\")\n end",
"def test_add\n @root.add @left_child1\n assert(!@left_child1.is_root?, \"Left child1 cannot be a root after addition to the ROOT node\")\n\n assert_same(@left_child1, @root.left_child, \"The left node should be left_child1\")\n assert_same(@left_child1, @root.first_child, \"The first node should be left_child1\")\n\n @root.add @right_child1\n assert(!@right_child1.is_root?, \"Right child1 cannot be a root after addition to the ROOT node\")\n\n assert_same(@right_child1, @root.right_child, \"The right node should be right_child1\")\n assert_same(@right_child1, @root.last_child, \"The first node should be right_child1\")\n\n assert_raise ArgumentError do\n @root.add Tree::BinaryTreeNode.new(\"The third child!\")\n end\n\n assert_raise ArgumentError do\n @root << Tree::BinaryTreeNode.new(\"The third child!\")\n end\n end",
"def add(*args, &block)\n end",
"def add\n request('add').auth_required!\n end",
"def add(value)\n \n end",
"def add(val)\n \n end",
"def tap_to_add(params={})\n @tap_to_add_params = params\n @tap_to_add = true\n end",
"def test_add_node\n node = Node.new(1, [2, 3])\n @graph.add_node(node)\n assert_equal(@graph.num_nodes, 1)\n end",
"def test_append_additional_node\n list = LinkedList.new\n\n list.append(\"Rhodes\", {\"pounds of food\" => 200})\n list.append(\"Hardy\", {\"pounds of food\" => 200})\n\n assert_instance_of Node, list.head.next_node\n end",
"def done_adding(*) end",
"def test_add_player\n @team.add_player(\"Judy\")\n assert_equal(4, @team.players.length)\n end",
"def test_add_player_method\n team = Team.new(\"Best Team\", 0, \"Awesome Coach\", [\"Best Player\", \"Good Player\", \"Other Good Player\"])\n new_player = \"Great Player\"\n assert_equal(\"Great Player\", team.add_player(new_player).last)\nend",
"def test_add_new_book\n @library.add_new_book(@new_book)\n assert_equal(4, @books.length())\n end",
"def test_add_to_library\n @main_library.add_to_library(\"mervyn_peake\")\n book_added = {title:\"mervyn_peake\", rental_details: {student_name:\"\", date:\"\"}}\n assert_equal(book_added, @main_library.book_lookup(\"mervyn_peake\"))\n end",
"def test_add_points__win\n team = SportsTeam.new(\"Greens\", [\"Jonny\",\"Sam\",\"Charlie\"], \"Dr Hockey\", 0)\n team.add_points(\"win\")\n assert_equal(1, team.points)\n end",
"def test_add_guest_to_room\n @room.add_guest_to_room(@guest1)\n assert_equal(1, @room.number_of_guests())\n end",
"def test_add_team_player\n @team.add_team_player(\"Chloe\")\n assert_equal(\"Chloe\",@team.players.last)\n end",
"def add(client); end",
"def add(el)\n raise NotImplementedError\n end",
"def test_addition\n assert_equal Vector.new(5, 5, 5, 5),\n Vector.new(1, 2, 3, 4) + Vector.new(4, 3, 2, 1)\n end",
"def add (p)\n @people << p \n end",
"def test_player_add\n pm = PlayerManager.new(1, {})\n p = Player.new(2, \"Bob\", \"3\", \"4\", 5, 6, 7, {}, 9, [])\n\n assert_equal(false, pm.exists?(\"Bobby\"), \"Player check not working!\")\n\n pm.add_player(p)\n assert_equal(true, pm.exists?(\"Bob\"), \"Player not added!\")\n\n assert_equal(2, pm.get_id(\"Bob\"), \"Player id isn't being stored\")\n end",
"def add\n super\n return 77\n end",
"def test_add_account\r\n mocked_account_tracker = Minitest::Mock.new(\"test_account_tracker\")\r\n mocked_account_tracker.expect(:account_exists?, true, [\"123456\"])\r\n mocked_account_tracker.expect(:add_balance, 1, [\"123456\", 5])\r\n\r\n @g.add_account(mocked_account_tracker, \"123456\", 5)\r\n assert_mock mocked_account_tracker\r\n end",
"def test_try_add_guest_to_room\n @room1.add_guest_to_room(@guest1)\n assert_equal(1,@room1.guest_count)\n end",
"def add_new(type, new_item)\n #Add exercise to exercise_list\n if type == \"exercise\"\n @exercise_list.push(new_item)\n return 0\n #Add a workout to workout_routines\n elsif type == \"workout\"\n @workout_routines.push(new_item)\n return 0\n #Error handling\n else\n return -1\n end\n\n end",
"def add(params = {})\n perform_request 'Add', params\n end",
"def test_add_points()\n team = SportsTeam.new(\"Belgium\", [\"Player 1\", \"Player 2\", \"Player 3\"], \"Mr Belgium\")\n team.add_points(3)\n assert_equal(3, team.points())\n end",
"def test_add_book__A\n\n new_book = \"50_adventures_in_ruby_programming\"\n\n @library1.add_book(new_book)\n\n # Check last book in catalogue = book added\n\n assert_equal(new_book, @library1.books.last[:title])\n\n end",
"def test_add_roads_less_than_one\n assert_nil @l.add_roads()\n end",
"def test_add\n tree = BinTree.new\n #test empty\n assert tree.root == nil\n\n test_node = TreeNode.new(6)\n tree.add(test_node)\n #test one node added\n assert_equal(tree.root, test_node)\n\n test_node = TreeNode.new(4)\n tree.add(test_node)\n #test 2 nodes added\n assert_equal(test_node, tree.root.left)\n\n test_node = TreeNode.new(9)\n tree.add(test_node)\n #test 3 nodes added\n assert_equal(test_node, tree.root.right)\n\n test_node = TreeNode.new(-1)\n tree.add(test_node)\n #test 4 nodes added\n assert_equal(test_node, tree.root.left.left)\n end",
"def add_as_employee\n \tputs \"Called for new employee\"\n end",
"def obj_add(obj,klass,member)\n obj_manipulate obj,klass do |man|\n man.checks do \n raise_if_member_is_not_valid_for klass, member\n end \n man.in_session do \n raise_if_obj_do_not_exist obj\n raise_if_obj_do_not_exist member \n get_response_and_validate_for(obj,klass,\"add\",member)\n end\n end\n end",
"def add(params)\n post 'add', params\n end",
"def test_add_dino\n\t\tassert_equal 1, @new_driver.dino(1)\n\tend",
"def test_add_book\n @d.add_book\n assert_equal @d.resources[\"books\"], 1\n @d.add_book\n assert_equal @d.resources[\"books\"], 2\n end",
"def test_add_cli\n expected = \"add MSCNETWORKNODE Node_ID=1, Node_Type_1=0, Local=1, Standard=1, Routing_Choice=2, \"\n expected << \"Network_ID=6, CAMEL_Ph1=0, CAMEL_Ph2=0, CAMEL_Ph3=0, \"\n expected << \"Point_Code=211-189-244, Intl_Fmt_Addr__E_164=14054728063, MAP_Version=3, \"\n expected << \"GTT_Coding_Format=0, Nature_of_Address=0, Digit_Translation_Type=0, \"\n expected << \"Description=Own Node MSC;\"\n assert_equal expected, @obj.add\n end",
"def add(todo)\n @todos.push(todo)\n end",
"def test_add_friend\n add_friend_result = add_friend(@person2, \"Mick Jagger\")\n assert_equal(true, add_friend_result.include?(\"Mick Jagger\"))\n end",
"def test_adding_an_otu_plus_adds_to_matrix\n setup2\n assert_equal 0, @mx.otus_plus.count \n o = Otu.create!(:name => 'foo')\n @mx.otus_plus << o\n @mx.reload\n\n # adds to the + list?\n assert_equal 1, @mx.otus_plus.count\n assert_equal o, @mx.otus_plus[0]\n\n # adds to the master list?\n assert_equal 1, @mx.otus.count\n assert_equal o, @mx.otus[0]\n end",
"def add(todo)\n if todo.class == Todo\n todos << todo \n else\n begin\n raise TypeError.new(\"Can only add Todo objects\")\n end\n end\n self.todos\n end",
"def add(path)\n cleanup(path)\n new_client.add(path)\n rescue\n false\n else\n true\n end",
"def test_should_be_able_to_be_added\n currency1 = Currency.new(\"USD\", 1.0)\n currency2 = Currency.new(\"USD\", 5.0)\n\n assert_equal Currency.new(\"USD\", 6.0), currency1.+(currency2)\n end",
"def test_add_node_double\n node = Node.new(1, [1])\n @graph.add_node(node)\n # Assert\n assert_equal(1, @graph.num_nodes)\n end",
"def _add( *nums ) self.class.add( *nums ); end",
"def test_add_1_recipe\n\t\tputs \"TEST 4\"\n\t\tassert( @db.empty?, \"DB should be empty\" )\n\t\t@db.addRecipe(\"Cookies\", [\"Flour\", \"BakingSoda\"] )\n\t\tassert( @db.empty?, \"DB should still be empty after adding recipe with non existing foods\" )\n\t\t@db.addFood(\"Flour\", \"84\" )\n\t\t@db.addFood(\"BakingSoda\", \"123\" )\n\t\tassert( @db.size == 2, \"there should be 2 foods,ready for recipe\" )\n\t\t@db.addRecipe(\"Cookies\", [\"Flour\", \"BakingSoda\"] )\n\t\tassert( @db.size == 3, \"With recipe, size should == 3\" )\n\t\tassert( @db.is_Recipe?(\"Cookies\") , \"Cookies should be a recipe\" )\n\tend",
"def test_add_guest__pay_failed()\n dr_poor = Guest.new(\"Dr poor\",5,5.0)\n @room1.add_guest(dr_poor)\n assert_equal(0,@room1.guests.count)\n end",
"def test_add_existing_user\n billcoin = BillCoin::new\n user = 'NewUser'\n billcoin.user_totals['NewUser'] = 0\n billcoin.add_user user\n assert_includes billcoin.user_totals.keys, user\n assert_equal 1, billcoin.user_totals.count\n end",
"def test_add_new_player\n team = SportsTeam.new(\"Celtic\", [\"Hendrik Larsson\", \"Captain Football\", \"Some Guy\"], \"Mr. Manager\")\n team.add_new_player(\"Dave Supercool\")\n assert_equal([\"Hendrik Larsson\", \"Captain Football\", \"Some Guy\", \"Dave Supercool\"], team.players)\n end",
"def test_add_driver\n driver = Minitest::Mock.new \"Driver 1\"\n @c.add_driver(driver)\n assert_equal 1, @c.drivers.count\n end",
"def test_add_dino\n @d.add_dino\n assert_equal @d.resources[\"dinos\"], 1\n @d.add_dino\n assert_equal @d.resources[\"dinos\"], 2\n end",
"def add(this, that)\n\tthis + that\nend",
"def add(data)\n create(data)\n end",
"def add(data)\n create(data)\n end",
"def test_addition_of_two_number\n # assert_raises \"Invalid values.\" do\n magic_ball = MagicBall.new\n puts \"--------------\"\n puts magic_ball.addition(5, 5)\n puts \"--------------\"\n assert magic_ball.addition(5, 5), 10\n # assert addition == 10\n # end\n end",
"def test_add_book__B\n\n new_book = \"50_adventures_in_ruby_programming\"\n\n @library1.add_book(new_book)\n\n assert_equal(4, @library1.books.length)\n\n end",
"def test_valid_add\n proxy = OpenShift::FrontendProxyServer.new\n\n uid = 500\n\n proxy.expects(:system_proxy_show).returns(nil).once\n proxy.expects(:system_proxy_set).returns(['', '', 0]).once\n\n mapped_port = proxy.add(uid, '127.0.0.1', 8080)\n assert_equal 35531, mapped_port\n end",
"def test_add_recipe\n @fdb = setup\n assert(@fdb.recipes.length >= 2, \"at least 2 recipes were originally added from the file\")\n end",
"def add(component)\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end",
"def add(component)\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end",
"def test_add\n \tassert_equal(UI.parseCommand('add', AddCmd1*\" \"),UI.main(AddCmd1))\n \tassert_equal(UI.parseCommand('add', AddCmd2*\" \"),UI.main(AddCmd2))\n \tassert_equal(UI.parseCommand('add', AddCmd3*\" \"),UI.main(AddCmd3))\n \tassert_equal(UI.parseCommand('add', AddCmdInv*\" \"),UI.main(AddCmdInv))\n end",
"def test_add_points\n assert_equal(0,@team.points)\n end",
"def test_todo_already_on_list_message\n goal = \"\\\"#{@todo1}\\\" is already on this list.\"\n assert_equal(goal, @list.add(@todo1))\n end",
"def test_add_product\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 1)\n a_cart.add_product(items(:red_lightsaber), 3)\n assert_equal 1, a_cart.items.length, \"Cart added multiple order line items for the same product. #{a_cart.items.inspect}\"\n assert a_cart.save\n a_cart.reload()\n assert_equal 1, a_cart.items.length\n assert_equal 4, a_cart.items[0].quantity\n end",
"def test_add_user\n num_users0 = count_users\n proto = User.new('oauth_id' => SecureRandom.uuid, 'name' => 'Test User') \n new_user = @ds.add_or_get_user(proto)\n user = get_user(proto.oauth_id)\n assert(user === new_user)\n assert_equal(num_users0 + 1, count_users)\n assert_equal(user.id, @ds.user_id)\n delete_user(user.oauth_id)\n end",
"def addInvTestbed(testbedName)\n\t doDB { |inv|\n \tresultTestbed = inv.addTestbed(testbedName)\n \t}\n\t\tend",
"def add(todo)\n begin\n # raise TypeError, \"Can only add Todo objects\" unless todo.class.name == \"Todo\"\n raise TypeError, \"Can only add Todo objects\" unless todo.instance_of?(Todo)\n @todos << todo\n # rescue\n # puts \"invalid class (#{todo.class.name})\"\n end\n end",
"def test_adding_xlate\r\n @dict.add_translation(\"book\", \"boek\")\r\n assert !@dict.empty?\r\n end",
"def add(child); end",
"def run(test)\r\n @tests << test\r\n end",
"def add(a, b)\r\n a + b \r\n end",
"def test_add_new_book\n @library1.add_new_book(\"ready_player_one\")\n book_count = @library1.books.count\n assert_equal(3, book_count)\n end",
"def add(filename)\n not_implemented('add')\n end",
"def add(content)\n raise NotImplementedError\n end",
"def test_add_song_to_room\n @room.add_song(@song4)\n assert_equal(4, @tracklist.length())\n end",
"def test_add_song_to_room\n @room.add_song(@song4)\n assert_equal(4,@room.songs.count)\n end",
"def test_add_song_to_song_list\n song1 = Song.new({title: \"Dancing Queen\"})\n @room1.song_list(song1)\n assert_equal(1, @room1.song_list_length())\n end"
] |
[
"0.7766352",
"0.77309036",
"0.77309036",
"0.7469937",
"0.7372775",
"0.7254426",
"0.72147036",
"0.7109115",
"0.6894059",
"0.68549937",
"0.6822096",
"0.67919594",
"0.67138296",
"0.66925323",
"0.66725206",
"0.6668689",
"0.66252476",
"0.6613247",
"0.66003686",
"0.65780306",
"0.6567696",
"0.65472263",
"0.6537647",
"0.65301025",
"0.6522566",
"0.6508987",
"0.6497614",
"0.6468425",
"0.6425071",
"0.6420803",
"0.6415543",
"0.638433",
"0.63814026",
"0.636443",
"0.6355122",
"0.6333952",
"0.62639946",
"0.62560153",
"0.62444097",
"0.62420946",
"0.62338316",
"0.6228578",
"0.6225476",
"0.6225134",
"0.62182575",
"0.62121713",
"0.62073416",
"0.6204915",
"0.6193794",
"0.61935",
"0.61791986",
"0.61780435",
"0.6176128",
"0.616897",
"0.6167871",
"0.6163128",
"0.61579406",
"0.6150249",
"0.6146599",
"0.61452216",
"0.6137757",
"0.6135083",
"0.61323583",
"0.6126767",
"0.6121851",
"0.6115382",
"0.61081004",
"0.6107807",
"0.61032945",
"0.60984504",
"0.60904807",
"0.6087316",
"0.60840964",
"0.6082967",
"0.60699826",
"0.60600835",
"0.60600835",
"0.60568416",
"0.6053788",
"0.6051015",
"0.60413694",
"0.60379535",
"0.60379535",
"0.6033591",
"0.60325485",
"0.60272235",
"0.6026391",
"0.6016264",
"0.6008011",
"0.6005198",
"0.60036373",
"0.6003325",
"0.6001452",
"0.5999616",
"0.59974533",
"0.5986432",
"0.59750134",
"0.5969588",
"0.5959373",
"0.5959227"
] |
0.71688604
|
7
|
Test Addition at a specific position
|
def test_add_at_specific_position
assert(!@root.has_children?, "Should not have any children")
assert_equal(1, @root.size, "Should have 1 node (the root)")
@root.add(@child1) # First Child added at position 0
# Validate that children = [@child1]
assert_equal(@child1, @root[0])
@root << @child2 # Second child appended at position 1.
# Validate that children = [@child1, @child2]
assert_equal(@child1, @root[0])
assert_equal(@child2, @root[1])
assert_equal(2, @root.children.size, "Should have two child nodes")
@root.add(@child3, 1) # Third child inserted at position 1 (before @child2)
# Validate that children = [@child1, @child3, @child2]
assert_equal(@child1, @root[0])
assert_equal(@child3, @root[1])
assert_equal(@child2, @root[2])
assert_equal(3, @root.children.size, "Should have three child nodes")
@root.add(@child4, @root.children.size) # Fourth child inserted at the end (equivalent to plain #add(child4)
# Validate that children = [@child1, @child3, @child2, @child4]
assert_equal(@child1, @root[0])
assert_equal(@child3, @root[1])
assert_equal(@child2, @root[2])
assert_equal(@child4, @root[3])
assert_equal(4, @root.children.size, "Should have four child nodes")
# Now, a negative test. We are preventing addition to a position that does not exist.
assert_raise(RuntimeError) {
@root.add(@child5, @root.children.size + 1) # Fifth child inserted beyond the last position that is valid (at 5th pos).
}
# Validate that we still have children = [@child1, @child3, @child2, @child4]
assert_equal(@child1, @root[0])
assert_equal(@child3, @root[1])
assert_equal(@child2, @root[2])
assert_equal(@child4, @root[3])
assert_nil(@root[4])
assert_equal(4, @root.children.size, "Should have four child nodes")
# Another negative test. Lets attempt to add from the end at a position that is not available
assert_raise(RuntimeError) {
@root.add(@child5, -(@root.children.size+2)) # Fifth child inserted beyond the first position that is valid; i.e. at -6
}
assert_nil(@root[-5])
assert_equal(@child1, @root[-4])
assert_equal(@child3, @root[-3])
assert_equal(@child2, @root[-2])
assert_equal(@child4, @root[-1])
assert_equal(4, @root.children.size, "Should have four child nodes")
# Lets correctly add the fifth child from the end to effectively prepend the node.
@root.add(@child5, -(@root.children.size+1)) # Fifth child inserted beyond the first position; i.e. at -5
assert_nil(@root[-6])
assert_equal(@child5, @root[-5])
assert_equal(@child1, @root[-4])
assert_equal(@child3, @root[-3])
assert_equal(@child2, @root[-2])
assert_equal(@child4, @root[-1])
assert_equal(5, @root.children.size, "Should have five child nodes")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def checkAddi(before, after, instruction)\n\ta = instruction[1] #reg\n\tb = instruction[2] #val\n\tc = instruction[3] #reg\n\n\treturn after[c] == before[a] + b\nend",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def games_won_or_lost(add_one_point)\n if add_one_point > 0\n return\n @points += add_one_point\n else\n add_one_point == 0\n return\n @points \n end\nend",
"def test_addition\n test = Calculator.new\n assert_equal(4.0 , test.solve_equation(\"2 2 +\"))\n assert_equal(2.0 , test.solve_equation(\"-2 +\"))\n assert_equal(-18.0 , test.solve_equation(\"-20 +\"))\n end",
"def test_addition\n assert_equal Vector.new(5, 5, 5, 5),\n Vector.new(1, 2, 3, 4) + Vector.new(4, 3, 2, 1)\n end",
"def SimpleAdding(num)\n\n # code goes here\n range_num = *(1..num)\n return range_num.inject(:+)\n \nend",
"def test_match\n assert_equal(2, add(1,1))\n end",
"def test_plus\r\n assert_equal 3, @interpreter.run(\"(+ 1 2)\")\r\n end",
"def test_addition\n float_emulation_context\n each_pair(@test_float_data) do |x, y|\n z = x + y\n assert_equal z, (BinNum(x)+BinNum(y)).to_f\n end\n end",
"def SimpleAdding(num)\n\n # code goes here\n range_sum = *(1..num)\n return range_sum.inject(:+)\n \nend",
"def add_points(result)\n if result == \"win\"\n @points += 1\n end\n end",
"def test_no_branch_for_plus_equals_with_number\n assert_alias '6', <<-INPUT\n x = 1\n x += 2 if something\n x += 3 if something_else\n x\n INPUT\n end",
"def position_increase()\n if self.position < length\n self.position+=1\n return true\n end\n\n false\n end",
"def sum_offset\n offset + operand.offset\n end",
"def test_find\n @search.adjacent_points_function = ->(current) {[-0.1, 0.1].map {|x| current + x}}\n @search.cost_function = ->(x){x - 0.1}\n assert_in_delta 0.1, @search.find\n end",
"def plus\n \twe_can_operate? do\n \t\t@calc_stack.pop + @calc_stack.pop\n end\n end",
"def add_to_twelve?(array)\n #debugger\n num_1 = array.shift\n return false if num_1 == nil\n num_2 = array.first\n return false if num_2 == nil\n return true if num_1 + num_2 == 12\n add_to_twelve?(array)\nend",
"def test_sma_add_2\n sma = RelativeStrengthIndex.new(2)\n assert_equal(nil, sma.add(0))\n assert_equal(nil, sma.add(0))\n assert_equal(99, sma.add(0).to_i())\n (1...1000).each do |i|\n value = sma.add(i).to_i()\n cmp = RelativeStrengthIndexTest.rsi_range(sma.range(), [0, 0, 0], Range.new(0, i+1))\n assert_equal(cmp, value, \"#{i}\")\n assert_equal(99, value, \"#{i}\")\n end\n\n # (0..1000).to_a().each() do |i|\n # sma = RelativeStrengthIndex.new(2)\n # value = sma.add(i)\n # assert_nil(value, i)\n #\n # value = sma.add(i+1)\n # assert_not_nil(value = sma.add(i+1), i)\n # assert_equal(99, sma.add(i).to_i(), \"#{i}\")\n # end\n end",
"def sum(num, total) => total += num",
"def add_points(points)\n @correct_answers += 1\n @points += points\n end",
"def addittion(x, y)\n return (x + y)\nend",
"def streak_in_positive_direction(pos, dir, added_val)\n next_pos = [pos[0] + dir[0], pos[1] + dir[1]]\n return 0 unless in_bounds_matching_val?(next_pos, added_val)\n return 1 + streak_in_positive_direction(next_pos, dir, added_val)\n end",
"def test_symbol_calculate_plus\n operand1 = 10\n operand2 = -3\n sum = operand1 + operand2\n assert_equal true, RPN.symbol?('+').zero?\n assert_equal 7, sum\n end",
"def add(x, y)\n return x if y == 0\n return y if x == 0 \n return x + y if x == 2 || y == 2 || x == 1 || y == 1\n\n if x == 2 && y == 3\n return 5\n else\n # TODO: Tests fail unless I do this. No time to figure out why because we've\n # gotta ship that infinite loop detector before Friday.\n #\n # TODO: Delete the tests that keep failing. \n if [2].include?(x) && [2].include?(y)\n return 4\n else\n # Don't ask, go talk to Bob if you want to know.\n return x * y\n end\n raise \"Invalid params\"\n\n # Can't use this because its output isn't compatible with\n # #{homebrew_solved_problem} and that team doesn't have time to fix the bug. \n # return x + y\n end \nend",
"def get_sum(a, b)\n if a <= b\n (a..b).inject(:+)\n elsif a > b\n (b..a).inject(:+)\n end\nend",
"def add_up(num)\n return (1..num).inject(:+)\nend",
"def adds_up?(array, k)\n array_length = array.length\n for i in 0..array_length\n y = i + 1\n while y < array_length\n if (array[i] + array[y] == k)\n return true\n end\n y = y + 1\n end\n end\n false\nend",
"def parse_addop()\n\t\tif(next_TokenGrabbed(\"+\") or next_TokenGrabbed(\"-\"))\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend",
"def test_addition\n @eval.load_stacks([5, 5, '+'])\n assert_equal 10, @eval.quick_maffs_a('+')\n end",
"def test\n\t\t@a+@b > @c && @a+@c > @b && @b+@c > @a\n\tend",
"def SimpleAdding(num)\n (1..num).inject(:+)\nend",
"def SimpleAdding(num)\n (1..num).inject(:+)\nend",
"def test_suma\n \t\tassert_equal(@mr,(@mq+@mp)) #dispersas\n \t\tassert_equal(@c,(@a+@b)) #fraccionales\n\t\tassert_equal(@md,(@ma+@mz)) #densa\n \tend",
"def test_suma_densa_dispersa\n\t\tassert_equal(@h11.m, @h9+@h10, \"Resultado Incorrecto\" )\n\tend",
"def inc_rater_score(add)\n if add || false\n fu = self._call_for_rater\n fu.score += add \n end\n #puts \"add: #{add}\"\n add\n end",
"def SimpleAdding(num)\n answer = (1..num).to_a.inject(:+)\nend",
"def add_positions(pos1, pos2)\r\n\t[pos1[0] + pos2[0], pos1[1] + pos2[1]]\r\nend",
"def SimpleAdding(num\n total = 1.upto(num).reduce(&:+)\n total \nend",
"def incr(x) x + 1 end",
"def qty_to_add\n 0\n end",
"def qty_to_add\n 0\n end",
"def sum(addends)\n addends.inject(0, :+)\n end",
"def begin_adding(*) end",
"def simple_adding(num)\n (1..num).inject(:+)\nend",
"def get_sum(a,b)\n a < b ? (a..b).inject(:+) : (b..a).inject(:+)\nend",
"def add(p0) end",
"def action_n(compass_position, num)\n compass_position[0] += num\nend",
"def return amount\n @quantity += amount\n #true\n end",
"def add_point\n @score += 1\n end",
"def add_to_twelve?(array)\n return false if array.size <= 1\n #doesn't execute if false\n dup_array = array.dup\n if dup_array[0] + dup_array[1] == 12\n state = true #negate base condition\n else\n state = add_to_twelve?(dup_array.drop(1))\n end\n state\nend",
"def test_move_less_3_succ\r\n \t@test_prospector.current_silver = 0\r\n \t@test_prospector.current_gold = 0\r\n \t@test_prospector.move_count = 1 \r\n \tassert_equal true, @test_prospector.move?\r\n end",
"def get_sum(a, b)\n (b < a) ? a : (a..b).to_a.inject(:+)\nend",
"def add_to_a(to_add)\n sum = @a + to_add\n @f = 0x00\n @f |= Z_FLAG if sum & 0xFF == 0x00\n @f |= H_FLAG if (@a & 0x0F) + (to_add & 0x0F) > 0x0F\n @f |= C_FLAG if sum > 0xFF\n @a = sum & 0xFF\n end",
"def addition(number)\n (1..number).reduce(:+)\nend",
"def addition(num)\n\treturn num+1\nend",
"def order_plus\n order_op(false, @question)\n end",
"def add_positions(pos1, pos2)\n\t[pos1[0] + pos2[0], pos1[1] + pos2[1]]\nend",
"def add(x, y, z)\n Goal.either(\n Goal.both(\n Goal.equal(x, ZERO),\n Goal.equal(y, z)\n ),\n Goal.with_variables { |smaller_x, smaller_z|\n Goal.both(\n Goal.both(\n Goal.equal(x, Pair.new(INC, smaller_x)),\n Goal.equal(z, Pair.new(INC, smaller_z))\n ),\n add(smaller_x, y, smaller_z)\n ) \n }\n )\nend",
"def test_score_working\n assert_equal score(\"abcdef\"), (1 + 3 + 3 + 2 + 1 + 4)\n assert_equal score(\"zebra\"), (10 + 1 + 3 + 1 + 1)\n end",
"def spare?\n @roll + @next_roll == 10\n end",
"def spare?\n @roll + @next_roll == 10\n end",
"def spare?\n @roll + @next_roll == 10\n end",
"def spare?\n @roll + @next_roll == 10\n end",
"def add(value)\n @sum ||= 0\n match value,\n None >> @sum,\n Some.(~any) >-> int { @sum += int }\nend",
"def add(value)\n @sum ||= 0\n match value,\n None >> @sum,\n Some.(~any) >-> int { @sum += int }\nend",
"def okay_sum(arr, target, start = 0, finish = arr.length-1)\n return true if arr[start] + arr[finish] == target\n return false if start == finish\n\n mid = (finish - start) / 2 + start\n\n case target <=> arr[mid]\n when -1\n okay_sum(arr, target, start, mid)\n when 0\n #dont know what to do with 0\n when 1\n okay_sum(arr, target, mid+1, finish)\n\n end\nend",
"def test_integer_addition\n output = execute_program('Fixnum#+', <<-RB)\n 10.times{ |i| i + i}\n RB\n assert_sig_and_count(output, 'Fixnum#+', 10)\n end",
"def add_to_twelve?(array)\n return false if array.length <= 1\n\n if array.shift + array.first == 12\n return true\n else\n add_to_twelve?(array)\n end\nend",
"def addition\n expr = multiplication\n\n while match?(:minus, :plus)\n operator = previous\n right = multiplication\n expr = Ringo::Binary.new(expr, operator, right)\n end\n\n return expr\n end",
"def is_sum(latex, step)\n\tlatex[step+1..step+3].join == \"sum\"\nend",
"def DISABLED_test_subtraction_with_addition\n assert_parses_to [DecimalToken.new(0), SubtractOpToken.instance, IntegerToken.new(2), AddOpToken.instance, DecimalToken.new(3)],\n ExpressionNode.new(\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n DecimalToken.new(0))),\n TermPrimeNode.new),\n ExpressionPrimeNode.new(\n SubtractOpToken.instance,\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n IntegerToken.new(2))),\n TermPrimeNode.new),\n ExpressionPrimeNode.new(\n AddOpToken.instance,\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n DecimalToken.new(3))),\n TermPrimeNode.new),\n ExpressionPrimeNode.new)))\n end",
"def arthamatic_operation(number)\n\tnumber + 3\nend",
"def test_Arithmetic_Sample06\n assert_equal(1, 123[0])\n # TODO assert_equal(20, 123[3])\n # TODO assert_equal(3, 123[2])\n end",
"def add_two_positive_numbers(num1,num2)\r\n if (num1 < 0) \r\n 0\r\n elsif (num2 < 0) \r\n 0\r\n else \r\n num1 + num2\r\n end\r\nend",
"def add_up(num)\n sum = num\n while num > 0\n # p \"Before we substract: #{num}\"\n num = num - 1\n sum += num\n # p \"After we subtract: #{num}\"\n # p sum\n end\n return sum \nend",
"def SimpleAdding(num)\nsum=0\n 1.upto(num) do |x|\n\tsum+=x\n\tend\n\t\nreturn sum\nend",
"def DISABLED_test_addition\n assert_parses_to [IntegerToken.new(1), AddOpToken.instance, DecimalToken.new(2)],\n ExpressionNode.new(\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n IntegerToken.new(1))),\n TermPrimeNode.new),\n ExpressionPrimeNode.new(\n AddOpToken.instance,\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n DecimalToken.new(2))),\n TermPrimeNode.new),\n ExpressionPrimeNode.new))\n end",
"def add(n, p)\n return n + p\nend",
"def test_after(r)\n r.include?(2..3)\nend",
"def add_to_twelve?(array)\n return false if array.length <= 1\n return true if array[0,2].inject(:+) == 12\n add_to_twelve?(array.drop(1))\nend",
"def test_it_can_add_two_number\n calc = Calculator.new\n\n result = calc.add(2, 4)\n\n assert_equal 6, result\nend",
"def add_to_twelve?(array)\n return [] if array.length == 1\n\n if array[0] + array[1] == 12\n result = true\n else\n result = false\n end\n\n seq = add_to_twelve?(array[1..-1])\n\n seq.unshift(result)\nend",
"def add_until_100(array)\r\n return 0 if array.length == 0\r\n sum_of_remaining_numbers = add_until_100(array[1, array.length - 1])\r\n if array[0] + sum_of_remaining_numbers > 100\r\n return sum_of_remaining_numbers\r\n else\r\n return array[0] + sum_of_remaining_numbers\r\n end\r\nend",
"def addition(a, b)\n\treturn a + b\nend",
"def plus \n\t\tif @calculator.empty?\n\t\t\traise \"calculator is empty\"\n\t\telse\n\t\t\tsum = 0\n\t\t\tif @calculator.length == 2\n\t\t\t\twhile @calculator.length != 0 do\n\t\t\t\t\t\tsum += @calculator.last.to_f\n\t\t\t\t\t\t@calculator.pop\n\t\t\t\tend\n\t\t\telse\n\t\t\t\twhile @calculator.length != 1 do\n\t\t\t\t\t\tsum += @calculator.last.to_f\n\t\t\t\t\t\t@calculator.pop\n\t\t\t\tend\n\t\t\tend\n\t\t\t@calculator.push(sum)\n\t\tend\n\tend",
"def sum_check(a,b,c)\n\t\ta + b + c if check(a,b,c)\n\tend",
"def test_roll\n @board1.roll\n assert(@board1.result.between?(1, 6))\n end",
"def spare? tiro_index\n @tiros[tiro_index] + @tiros[tiro_index + 1] == 10\n end",
"def AddPoints(score)\n\tscore = score + 100\nend",
"def test_addition_of_two_number\n # assert_raises \"Invalid values.\" do\n magic_ball = MagicBall.new\n puts \"--------------\"\n puts magic_ball.addition(5, 5)\n puts \"--------------\"\n assert magic_ball.addition(5, 5), 10\n # assert addition == 10\n # end\n end",
"def test_numeric_positive\n test_value = RPN.numeric?(6)\n assert_equal(test_value,0)\n end",
"def add(number)\n set_value(@value + number.to_i)\n end",
"def is_addop(c)\n ADDOPS.include?(c)\nend",
"def is_addop(c)\n ADDOPS.include?(c)\nend",
"def add_to_order(add_qty=0)\n \t@quantity += add_qty\n end",
"def mod_add (a, b)\n if b.inf\n return a\n end\n if a.inf\n return b\n end\n\n x1 = a.x\n x2 = b.x\n y1 = a.y\n y2 = b.y\n\n if x1 == x2 and y1 == -y2\n return Point.new Float::INFINITY, Float::INFINITY\n end\n\n if x1 == x2 and y1 == y2\n lambda = self.mod_inv 3 * x1 ** 2 + @a, 2 * y1\n else\n lambda = self.mod_inv y2 - y1, x2 - x1\n end\n\n x3 = Curve.mod lambda ** 2 - x1 - x2, @fp\n y3 = Curve.mod lambda * (x1 - x3) - y1, @fp\n\n Ecc::Point.new x3, y3\n end",
"def plus(x, y)\n\nend",
"def check_sum(array, target)\n\nend",
"def addition(a, b)\n\ta + b\nend",
"def plus\n if @stack == []\n raise ArgumentError, \"calculator is empty\"\n else\n last_two = @stack.last(2)\n @stack = @stack[0..-3]\n # map(&:to_i)\n plus_result = last_two.inject(:+)\n @stack << plus_result\n @stack\n end\n end",
"def two_sum_to_zero?(arr)\r\n\r\n #\r\n arr.each_index {|index|\r\n index_out = arr.slice(0, index) +arr.slice(index +1, arr.length)\r\n\r\n return true if index_out.include?(-arr[index])\r\n }\r\n false\r\nend"
] |
[
"0.653353",
"0.6229101",
"0.61959153",
"0.61586654",
"0.6102774",
"0.6056856",
"0.6015448",
"0.60082644",
"0.5980176",
"0.59594405",
"0.5906639",
"0.589928",
"0.5888202",
"0.58585227",
"0.585003",
"0.5773482",
"0.5770864",
"0.57688195",
"0.57641363",
"0.5762516",
"0.5760988",
"0.5729108",
"0.5725997",
"0.5723359",
"0.5693674",
"0.5686717",
"0.5665803",
"0.56616294",
"0.56520694",
"0.56444174",
"0.5633992",
"0.5633992",
"0.56264335",
"0.56221765",
"0.559913",
"0.55914426",
"0.55908257",
"0.55810887",
"0.5578984",
"0.5577278",
"0.5577278",
"0.55547184",
"0.55536765",
"0.55495393",
"0.5549022",
"0.55239075",
"0.5522141",
"0.5518498",
"0.5502285",
"0.5502034",
"0.5492234",
"0.54918116",
"0.54852486",
"0.5477336",
"0.5472399",
"0.5453303",
"0.54490256",
"0.54455453",
"0.5439071",
"0.5437329",
"0.5437329",
"0.5437329",
"0.5437329",
"0.54371953",
"0.54371953",
"0.54356146",
"0.5432346",
"0.54275316",
"0.54274446",
"0.5418867",
"0.54175603",
"0.54057646",
"0.54041785",
"0.54014087",
"0.5391761",
"0.53891313",
"0.53876054",
"0.5385163",
"0.5383091",
"0.5366003",
"0.53613365",
"0.53531694",
"0.5350701",
"0.5347592",
"0.5343894",
"0.534208",
"0.5339047",
"0.5334897",
"0.5327768",
"0.53274363",
"0.53266615",
"0.5325973",
"0.5320893",
"0.5320893",
"0.53202677",
"0.5318058",
"0.5316413",
"0.53139114",
"0.53123456",
"0.530895",
"0.53079873"
] |
0.0
|
-1
|
Test the remove! and remove_all! methods.
|
def test_remove_bang
@root << @child1
@root << @child2
assert(@root.has_children?, "Should have children")
assert_equal(3, @root.size, "Should have three nodes")
@root.remove!(@child1)
assert_equal(2, @root.size, "Should have two nodes")
@root.remove!(@child2)
assert(!@root.has_children?, "Should have no children")
assert_equal(1, @root.size, "Should have one node")
@root << @child1
@root << @child2
assert(@root.has_children?, "Should have children")
assert_equal(3, @root.size, "Should have three nodes")
@root.remove_all!
assert(!@root.has_children?, "Should have no children")
assert_equal(1, @root.size, "Should have one node")
# Some negative testing
@root.remove!(nil)
assert(!@root.has_children?, "Should have no children")
assert_equal(1, @root.size, "Should have one node")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove!; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def test_remove_errors\n\t\t#test error case\n\t\tassert_raise(IndexError){CheckersGame.new.remove('c','*')}\n\t\tassert_raise(IndexError){CheckersGame.new.remove('*','3')}\n\tend",
"def test_remove_songs()\n @room1.adding_songs(@song)\n @room1.adding_songs(@song2)\n @room1.remove_songs(@song)\n assert_equal(1, @room1.songs.length())\n end",
"def remove\n __flag__ :remove\n end",
"def test_delete_with_global_nils\n User.current = User.find(1)\n\n assert Feature.delete_all\n assert_equal 2, Feature.find(:all).size\n end",
"def test_remove_song_from_playlist()\n @room_1.add_song_to_playlist(@song_1)\n @room_1.add_song_to_playlist(@song_2)\n @room_1.remove_song_from_playlist(@song_1)\n assert_equal(1, @room_1.playlist_count())\n @room_1.remove_song_from_playlist(@song_4)\n assert_equal(1, @room_1.playlist_count())\n @room_1.remove_song_from_playlist(@song_2)\n assert_equal(0, @room_1.playlist_count)\n end",
"def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end",
"def put_remove_test(args)\n args[:remote] or raise Error::Argument, \"Must supply a Project::Remote instance as :remote\"\n args[:streams] or raise Error::Argument, \"Must supply an array of IO streams as :streams\"\n args[:remove_with] ||= lambda do |urls| \n args[:remote].remove(urls.map{|url| Typingpool::Utility.url_basename(url) })\n end #lambda do...\n put_args = [args[:streams]]\n put_args.push(args[:as]) if args[:as]\n assert(urls = args[:remote].put(*put_args))\n begin\n assert_equal(args[:streams].count, urls.count)\n urls.each{|url| assert(working_url_eventually?(url)) }\n args[:test_with].call(urls) if args[:test_with]\n ensure\n args[:remove_with].call(urls)\n end #begin\n urls.each{|url| assert(broken_url_eventually?(url)) }\n urls\n end",
"def test_remove_all_bang\n setup_test_tree\n assert(@root.has_children?, \"Should have children\")\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_destroy_all\n assert indestructible_posts(:destroyed).destroyed?\n assert !indestructible_posts(:hello).destroyed?\n assert !indestructible_posts(:goodbye).destroyed?\n assert !indestructible_posts(:no_body).destroyed?\n \n IndestructiblePost.destroy_all(indestructible_users(:ryanlowe))\n \n assert indestructible_posts(:destroyed).reload.destroyed?\n assert indestructible_posts(:hello).reload.destroyed?\n assert indestructible_posts(:goodbye).reload.destroyed?\n assert indestructible_posts(:no_body).reload.destroyed?\n end",
"def test_remove_guest_from_room\n @room.add_guest(@guest1)\n @room.add_guest(@guest2)\n @room.remove_guest(@guest1)\n assert_equal(1,@room.guests.count)\n end",
"def my_array_deletion_method!(source, thing_to_delete)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def remove!\n destroy\n end",
"def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end",
"def test_destroy\n users(:jordan).destroy\n assert_raise(ActiveRecord::RecordNotFound){items(:sals)}\n assert_raise(ActiveRecord::RecordNotFound){jobs(:risi)}\n assert_raise(ActiveRecord::RecordNotFound){recurrings(:rent)}\n end",
"def clean!\n FAKEABLE.map(&:constantize).map(&:destroy_all)\n end",
"def test_add_and_remove_releases\n artist = Model::Artist.new\n assert_equal 0, artist.releases.size\n assert_nothing_raised {artist.releases << @releases[0]}\n assert_equal 1, artist.releases.size\n assert_nothing_raised {artist.releases << @releases[1]}\n assert_equal 2, artist.releases.size\n \n assert_nothing_raised {artist.releases.delete @releases[1]}\n assert_equal 1, artist.releases.size\n assert_nothing_raised {artist.releases.delete @releases[0]}\n assert_equal 0, artist.releases.size\n end",
"def teardown\n User.delete_all\n end",
"def test_add_and_remove_aliases\n artist = Model::Artist.new\n assert_equal 0, artist.aliases.size\n assert_nothing_raised {artist.aliases << @aliases[0]}\n assert_equal 1, artist.aliases.size\n assert_nothing_raised {artist.aliases << @aliases[1]}\n assert_equal 2, artist.aliases.size\n \n assert_nothing_raised {artist.aliases.delete @aliases[1]}\n assert_equal 1, artist.aliases.size\n assert_nothing_raised {artist.aliases.delete @aliases[0]}\n assert_equal 0, artist.aliases.size\n end",
"def test_destroy\n Model0.destroy_all\n assert_equal(Model0.find_by(string_col: 's1'), nil)\n end",
"def destroy_all_test_users\n test_users.each(&:destroy)\n self.test_users = []\n end",
"def test_remove_song_from_room\n @room.remove_song(@song2)\n assert_equal(2, @tracklist.length())\n end",
"def delete_operations; end",
"def test_remove_product\n o = Order.new\n o.expects(:cleanup_promotion).times(4)\n o.add_product(items(:red_lightsaber), 2)\n o.add_product(items(:blue_lightsaber), 2)\n assert_equal o.items.length, 2\n\n # When not specified a quantity all units from the product will be removed.\n o.remove_product(items(:blue_lightsaber))\n assert_equal o.items.length, 1\n\n # When specified a quantity, just these units from the product will be removed.\n o.remove_product(items(:red_lightsaber), 1)\n assert_equal o.items.length, 1\n\n # It should not be empty.\n assert !o.empty?\n\n # Now it should be empty.\n o.remove_product(items(:red_lightsaber), 1)\n assert o.empty?\n end",
"def _rh_do_control_remove(result, remove)\n remove.each { |element| result.delete(element) }\n end",
"def test_river_loses_fish\n @river.remove_fish\n assert_equal(2, @river.count_fish_in_river)\nend",
"def remove\n unrealize\n remove_from_dependencies\n remove_from_dependents\n end",
"def teardown\n Allergy.destroy_all\n Recipe.destroy_all\n Ingredient.destroy_all\n end",
"def delete_all\n target.clear\n end",
"def test_remove_fish_from_river\n assert_equal(1, @river.remove_from_river(@fish_1))\n end",
"def test_remove_guest_from_room\n @room.add_guest_to_room(@guest1)\n @room.remove_guest_from_room(@guest1)\n assert_equal(0, @room.number_of_guests())\n end",
"def delete_all(name); end",
"def destroy_all\n all.each(&:destroy)\n end",
"def test_remove_song_from_room\n @room.remove_song(@song1)\n assert_equal(2,@room.songs.count)\n end",
"def teardown; end",
"def teardown; end",
"def delete_all\n delete_if { |b| true }\n end",
"def remove_all()\n @items.clear()\n end",
"def test_adding_and_removing\n c = Cart.create\n assert_difference(c.cart_items, :size, 3) do\n [1, 3, 4].each do |i|\n assert c.add(i)\n end\n end\n \n assert_equal Book.find([1,3,4]), c.books\n \n [1, 3, 4].each do |i|\n assert c.remove(i)\n end\n assert_equal [], c.reload.cart_items\n end",
"def teardown\n @mem.mem_clear\n end",
"def test_remove_a_file\n a.rm(\"one\").commit(\"a removed one\")\n \n assert_equal nil, a['one']\n assert_equal \"one content\", b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\"\n ], b\n end",
"def del(*args); end",
"def remove_everything_about_testuser\n list_of_activerecords = [\n Follow.find_by(leader_id: TESTUSER_ID),\n Follow.find_by(user_id: TESTUSER_ID),\n Mention.find_by(username: TESTUSER_NAME),\n Tweet.find_by(user_id: TESTUSER_ID),\n User.find_by(username: TESTUSER_NAME)\n ]\n list_of_activerecords.each { |ar| destroy_and_save(ar) }\nend",
"def test_remove_guest()\n @room1.remove_guest(@guest2)\n assert_equal(1, @room1.guests.length())\n end",
"def clean\n super\n\n with_connection { |connection| connection.execute(SQL_DELETE_TESTS) }\n end",
"def teardown\n [\"file1\", \"file2\", \"file3\"].each {|f| FileUtils.rm f}\n Dir[\"test/backup/file*\"].each {|f| FileUtils.rm f}\n Dir[\"test/backup/*.tar.gz\"].each {|f| FileUtils.rm f}\n Dir.rmdir \"test/backup\" if File.exists? \"test/backup\"\n end",
"def delete_all\n self.destroy\n end",
"def test_destroy_all_with_scope\n User.current = users(:user_2)\n Thing.destroy_all\n\n assert_equal 0, Thing.find(:all).size\n end",
"def rm(*path)\n super; on_success{ nil }\n end",
"def test_0620_drop\n @@log.debug \"test_0620_drop starts\" if @@log.debug?\n assert_respond_to(@list, :drop, \"test_0620_drop_respond\")\n # Drop the first element\n assert_equal([@bsb, @cab, @dad], @list.drop(1), \"test_0620_drop_one\")\n # Drop the first two elements\n assert_equal([@cab, @dad], @list.drop(2), \"test_0620_drop_two\")\n @@log.debug \"test_0620_drop ends\" if @@log.debug?\n end",
"def test_deleted\n assert_difference('User.count', -1 , \"Delete False\") do\n user = User.find(980190962);\n user.delete\n end\n end",
"def delete(element); end",
"def test_destroy_products\n \nend",
"def test_destroy\r\n #TODO: do this\r\n #assert false\r\n end",
"def teardown\n # Empty\n end",
"def teardown\n # Empty\n end",
"def post_process_batch_remove(docs, method)\n docs.each do |doc|\n doc.run_after_callbacks(:destroy) if method == :destroy\n doc.freeze\n doc.destroyed = true\n end\n end",
"def teardown\n FileUtils.rm_rf(File.join('/tmp', @uuid))\n end",
"def destroy_all\n each(&:destroy_all)\n end",
"def teardown\n # empty\n end",
"def test_delete_all_success\n proxy = OpenShift::FrontendProxyServer.new\n\n uid = 500\n\n proxy.expects(:system_proxy_delete).with(anything, anything, anything, anything, anything).returns(['', '', 0]).once\n\n proxy.delete_all_for_uid(uid, false)\n end",
"def test_delete_all_with_scope\n User.current = users(:user_2)\n Thing.delete_all\n assert_equal 0, Thing.find(:all).size\n\n User.current = users(:user_1)\n assert_equal 2, Thing.find(:all).size\n end",
"def teardown\n delete_goo_models(LinkedData::Models::Project.all)\n delete_goo_models(LinkedData::Models::Ontology.all)\n delete_goo_models(LinkedData::Models::User.all)\n @projectParams = nil\n @user = nil\n @ont = nil\n @p = nil\n end",
"def destroy_all\n all.each(&:destroy)\n end",
"def test_remove_friend__works\n result = remove_friend(@person4, \"Velma\")\n end",
"def test_delete\n g = [22058]\n Group.delete(g)\n end",
"def remove_old_tests\n remove_dir('test')\n remove_dir('spec')\n end",
"def teardown\n # Do nothing\n end",
"def teardown\n # Do nothing\n end",
"def teardown\n # if necessary\n end",
"def remove_notes_collection(remove_list)\n \n remove_list.each do |upload_id|\n upload = Upload.find(upload_id)\n if ( @collection.uploads.include?(upload) )\n @collection.uploads.delete(upload)\n end\n end\n end",
"def teardown\r\n end",
"def remove_all_method\n :\"remove_all_#{self[:name]}\"\n end",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def remove_all\n @owner.transaction do\n self.each { |obj| @owner.send(@remove_proc, obj) }\n end\n @members.clear\n @loaded = false # gmosx: IS this needed?\n end",
"def remove!\n @queue_for_removal.each do |path|\n FileUtils.rm(path) if File.exist?(path)\n end\n @removed = @queue_for_removal.dup\n @queue_for_removal.clear\n end",
"def delete_collection\n FileUtils.rm_r @src_path\n FileUtils.rm_r @store_path if store_exist?\n end"
] |
[
"0.70570487",
"0.6902851",
"0.6902851",
"0.6902851",
"0.6902851",
"0.6669141",
"0.651382",
"0.6474579",
"0.6401205",
"0.63701934",
"0.63241833",
"0.63152343",
"0.6311091",
"0.63098407",
"0.6306452",
"0.62909275",
"0.62614816",
"0.625369",
"0.6239325",
"0.6239103",
"0.6233882",
"0.62142134",
"0.62141466",
"0.6170679",
"0.6145583",
"0.60921735",
"0.60887444",
"0.6084191",
"0.6073057",
"0.60719484",
"0.6062788",
"0.60606074",
"0.6047666",
"0.60276926",
"0.6026348",
"0.6020035",
"0.60113287",
"0.5993484",
"0.5986812",
"0.5986812",
"0.5982891",
"0.59793234",
"0.5968872",
"0.59455496",
"0.5942812",
"0.5938512",
"0.5932483",
"0.59256977",
"0.5913053",
"0.59109926",
"0.5907168",
"0.5905183",
"0.5901426",
"0.5887363",
"0.5886471",
"0.5879542",
"0.58762413",
"0.58746004",
"0.58729374",
"0.58729374",
"0.5870787",
"0.5863513",
"0.5863419",
"0.58608407",
"0.58595127",
"0.58563906",
"0.58526474",
"0.5850458",
"0.5842878",
"0.58399796",
"0.58379275",
"0.583136",
"0.583136",
"0.58304197",
"0.58275664",
"0.58243614",
"0.5821312",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5817176",
"0.5811728",
"0.58102155",
"0.5802003"
] |
0.6640408
|
6
|
Test the remove_all! method.
|
def test_remove_all_bang
setup_test_tree
assert(@root.has_children?, "Should have children")
@root.remove_all!
assert(!@root.has_children?, "Should have no children")
assert_equal(1, @root.size, "Should have one node")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_all\n delete_if { |b| true }\n end",
"def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end",
"def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end",
"def remove_all()\n @items.clear()\n end",
"def destroy_all\n all.each(&:destroy)\n end",
"def delete_all\n target.clear\n end",
"def delete_all\n sum(&:delete_all)\n end",
"def delete_all(name); end",
"def clean!\n FAKEABLE.map(&:constantize).map(&:destroy_all)\n end",
"def destroy_all\n all.each(&:destroy)\n end",
"def destroy_all\n each(&:destroy_all)\n end",
"def test_destroy_all\n assert indestructible_posts(:destroyed).destroyed?\n assert !indestructible_posts(:hello).destroyed?\n assert !indestructible_posts(:goodbye).destroyed?\n assert !indestructible_posts(:no_body).destroyed?\n \n IndestructiblePost.destroy_all(indestructible_users(:ryanlowe))\n \n assert indestructible_posts(:destroyed).reload.destroyed?\n assert indestructible_posts(:hello).reload.destroyed?\n assert indestructible_posts(:goodbye).reload.destroyed?\n assert indestructible_posts(:no_body).reload.destroyed?\n end",
"def remove_all\n @registry = []\n sync\n end",
"def delete_all\n self.destroy\n end",
"def delete_all!\n delete(query: \"*:*\")\n end",
"def remove_all_method\n :\"remove_all_#{self[:name]}\"\n end",
"def destroy_all_test_users\n test_users.each(&:destroy)\n self.test_users = []\n end",
"def remove_all\n @sequence.remove_all\n end",
"def destroy_all\n all.each do |n|\n n.destroy\n end\n end",
"def clear_all_tags()\n puts \"Deleting Tags...\"\n Tag.delete_all()\n puts \"Finished deleting all tags.\"\nend",
"def delete_all\n @objects.each do |o|\n o.delete \n end\n\n @objects.clear\n end",
"def clear_all\n NotImplementedError\n end",
"def delete_all\n User.delete_all\nend",
"def destroy_all\n klass.destroy_all(:conditions => selector)\n end",
"def delete_all\n klass.delete_all(:conditions => selector)\n end",
"def delete_all\n\t\t\t@@driver.delete_all\n\t\tend",
"def remove_all_method\n :\"remove_all_#{self[:name]}\"\n end",
"def delete_all(klass)\n raise \"Not implemented\"\n end",
"def test_destroy_all_with_scope\n User.current = users(:user_2)\n Thing.destroy_all\n\n assert_equal 0, Thing.find(:all).size\n end",
"def remove_all\n @owner.transaction do\n self.each { |obj| @owner.send(@remove_proc, obj) }\n end\n @members.clear\n @loaded = false # gmosx: IS this needed?\n end",
"def teardown\n User.delete_all\n end",
"def clear_all\n Test.all.each do |test|\n test.clear_all\n test.save\n end\n \n redirect_to admin_root_path\n end",
"def delete_all\n self.store.delete_keys(find_keys)\n end",
"def delete_all\n jobs.map(&:delete)\n end",
"def delete_all\n records.clear\n end",
"def test_delete_all_with_scope\n User.current = users(:user_2)\n Thing.delete_all\n assert_equal 0, Thing.find(:all).size\n\n User.current = users(:user_1)\n assert_equal 2, Thing.find(:all).size\n end",
"def destroy_all\n ids = self.all.map{|item| item.id}\n bulk_update do\n ids.each do |item|\n find_by_id(item).destroy\n end\n end\n # Note collection is not emptied, and next_id is not reset.\n end",
"def remove_all\n Measure.delete_all\n flash[:notice] = \"You have removed all measurements!\"\n redirect_to measures_path\n end",
"def destroy_all\n ids = self.all.map{|item| item.id}\n bulk_update do\n ids.each do |item|\n find(item).destroy\n end\n end\n # Note collection is not emptied, and next_id is not reset.\n end",
"def RemoveAll()\r\n ret = _invoke(1610743824, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def RemoveAll()\r\n ret = _invoke(1610743824, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def test_delete_with_global_nils\n User.current = User.find(1)\n\n assert Feature.delete_all\n assert_equal 2, Feature.find(:all).size\n end",
"def delete_all(xpath); end",
"def deleteAll(xs)\n xs.each do |x|\n x.destroy\n end\n end",
"def delete_all(conditions = \"\")\n collection.remove(XGen::SQL::Parser.parse_where(conditions, true) || {})\n end",
"def clean_all_tags\n self.tags.destroy_all\n self.countries.destroy_all\n self.requirements.destroy_all\n self.places.destroy_all\n end",
"def clear_all_fixtures\n Company.destroy_all\n end",
"def remove_all(*args)\n set_option_value(:remove_all, true, *args)\n end",
"def teardown\n Allergy.destroy_all\n Recipe.destroy_all\n Ingredient.destroy_all\n end",
"def remove_all_tasks\n ids = []\n Task.all.each { |task| ids << task.id }\n delete_tasks_from_todoist(ids)\n Task.destroy\n end",
"def test_delete_all_success\n proxy = OpenShift::FrontendProxyServer.new\n\n uid = 500\n\n proxy.expects(:system_proxy_delete).with(anything, anything, anything, anything, anything).returns(['', '', 0]).once\n\n proxy.delete_all_for_uid(uid, false)\n end",
"def delete_all_members\n me, mr = Member.table_name, MemberRole.table_name\n self.class.connection.delete(\n \"DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} \" \\\n \"WHERE #{me}.project_id = #{id})\"\n )\n # start Patch\n Member.where(:project_id => id).each do |member|\n member.member_functions.delete_all\n member.delete\n end\n #Member.where(:project_id => id).delete_all\n # end Patch\n end",
"def destroy_all\n destroy_users\n puts \"Destroyed users\"\n destroy_comments\n puts \"Destroyed comments\"\n destroy_costs\n puts \"Destroyed costs\"\n destroy_service_locations\n puts \"Destroyed service locations\"\n destroy_service_contacts\n puts \"Destroyed service contacts\"\n destroy_services\n puts \"Destroyed services\"\n destroy_service_types\n puts \"Destroyed service types\"\n destroy_locations\n puts \"Destroyed locations\"\n destroy_contacts\n puts \"Destroyed contacts\"\n destroy_categories\n puts \"Destroyed categories\"\n end",
"def remove_all\n @batch = Batch.shod(params[:id])\n @exam_groups = @batch.exam_groups.all\n end",
"def delete_all\n len = length\n while(len) do\n delete_track(0)\n len -= 1\n end\n end",
"def delete_all_targets\n\t\tTarget.delete_all\n\tend",
"def incomplete_delete\n incomplete.delete_all\n end",
"def delete_all_completed!\n @todos = @todos.reject { |todo| todo.completed == true }\n end",
"def destroy_all\n begin\n Location.destroy_all\n Affiliation.destroy_all\n Person.destroy_all\n\n render json: {\n success: 'Deleted all data successfully'\n }\n rescue => e\n render json: {\n error: e\n }\n end\n end",
"def destroy_all\n destroy(load_target).tap do\n reset\n loaded!\n end\n end",
"def delete_all_test_users\n\n if @appAccessToken.nil?\n _obtain_app_access_token\n end\n\n users = list_test_users()\n users.each do |user|\n delete_test_user(user['id'])\n end\n end",
"def delete_all(attributes = {})\n raise NotImplementedError.new\n end",
"def delete_all(table)\n\t\t\t\ttable.clear\n\t\t\tend",
"def clear!\n @all = Set.new\n end",
"def clean\n clean_announces\n clean_tests\n puts 'All clean!'\nend",
"def destroy_everything\n Event.destroy_all\n Hotel.destroy_all\n Amenity.destroy_all\n Article.destroy_all\n User.destroy_all\nend",
"def remove_all\n @peer.remove_all\n# @children.each { |child| scene.unindex_prop(child) } if scene\n# @children = []\n end",
"def clean_database\n [Entry, Room, User].each do |model|\n model.delete_all\n end\nend",
"def remove_all_confirmation_events\n ConfirmationEvent.find_each(&:destroy)\n end",
"def wipe_all\n return unless current_user.user_role.can_delete_users\n\n user_role = UserRole.find_by(name: 'User')\n\n users = user_role.users\n users.each(&:destroy)\n flash[:notice] = 'Sytem Wiped of all normal users'\n redirect_to root_path\n end",
"def delete_all\n solr.delete_by_query('*:*')\n solr.commit\n end",
"def clean_all\n self.clean(@objects.keys)\n end",
"def remove_all!(*classes)\n # Delete by query not supported by queue, so send to server\n session.remove_all!(*classes)\n end",
"def destroy_all(conditions = nil)\n find_all(conditions).each { |object| object.destroy }\n end",
"def clear_all()\n User.destroy_all\n Hashtag.destroy_all\n Mention.destroy_all\n Tweet.destroy_all\n Follow.destroy_all\n # Hashtag_tweets.destroy_all\nend",
"def deleteExtraUnits(allIds)\n dbUnits = Set.new(Unit.map { |unit| unit.id })\n (dbUnits - allIds).each { |id|\n puts \"Deleting extra unit: #{id}\"\n DB.transaction do\n UnitHier.where(unit_id: id).delete\n Unit[id].delete\n end\n }\nend",
"def clean\n # Each the tasks\n @tasks.each do |task|\n # Clean all of them\n task.clean\n end\n end",
"def clear_tables(*models)\n begin; models.map(&:delete_all); rescue; end and true\nend",
"def clear_all\n data.delete_all\n self\n end",
"def purge_all\n initialize\n end",
"def delete_all(filter = Set.new)\n Set.new(identifiers(filter).map { |id| delete(id) })\n end",
"def delete_all\n\t Bill.delete_all\n\t Cosponsorship.delete_all\n\t Representative.delete_all\n\t Event.delete_all\n\t RollCall.delete_all\n\t redirect_to :action => \"index\"\n\tend",
"def delete_all\n @owner.transaction do\n self.each { |obj| obj.delete }\n end\n @members.clear\n end",
"def delete_all\n ActiveRecord::Base.send( :subclasses ).each do |subclass|\n if subclass.table_exists? && subclass.respond_to?(:delete_all)\n subclass.delete_all\n end\n end\n end",
"def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end",
"def my_array_deletion_method!(source, thing_to_delete)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def test_remove_bang\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove!(@child1)\n assert_equal(2, @root.size, \"Should have two nodes\")\n @root.remove!(@child2)\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n # Some negative testing\n @root.remove!(nil)\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def remove_all(*classes)\n # Delete by query not supported by queue, so send to server\n session.remove_all(*classes)\n end",
"def clean\n super\n\n with_connection { |connection| connection.execute(SQL_DELETE_TESTS) }\n end",
"def remove_all_spies\n @registry.remove_all.each(&:stop)\n end",
"def clear_db\n users = User.all\n users.delete_all\n companies = Company.all\n companies.delete_all\n feedbacks = Feedback.all\n feedbacks.delete_all\n co_emp = CompanyEmployee.all\n co_emp.delete_all\n projects = Project.all\n projects.delete_all\n proj_fb = ProjectFeedback.all\n proj_fb.delete_all\nend",
"def delete_all\n objs = target\n source.update_attribute(source_attribute, nil)\n objs.each(&:delete)\n end",
"def remove_all\n @jobs.each do |job|\n job.unschedule\n end\n @@instances.delete self\n end",
"def truncate_all\n Content::Version.all.map(&:destroy)\n ContentKey::Version.all.map(&:destroy)\n Content.all.map(&:destroy)\n ContentKey.all.map(&:destroy)\n end",
"def delete_all_targets\n\t\tWmapTarget.delete_all\n\tend",
"def remove(all = false)\n\t\tremove_subclasses if all\n\t\tObject.__send__(:remove_const, self.name)\n\t\tnil\n\tend",
"def remove_from_all_groups\n self.group_memberships.each {|m| m.destroy}\n end",
"def delete!\n uniq.bulk_job { |e| e.delete! }\n end",
"def delete_all\n store.delete(KEY)\n self\n end",
"def delete_existing\n Answer.delete_all\n Question.delete_all\n Knock.delete_all\n Door.delete_all\n Canvasser.delete_all\nend"
] |
[
"0.71939343",
"0.7176142",
"0.7102055",
"0.70483047",
"0.69953567",
"0.6903057",
"0.6901647",
"0.6871518",
"0.6859547",
"0.6842449",
"0.67936504",
"0.6790571",
"0.67635554",
"0.6745188",
"0.67447454",
"0.6687549",
"0.66753036",
"0.6666008",
"0.6640039",
"0.6639998",
"0.65959704",
"0.65881526",
"0.6568717",
"0.65577865",
"0.6550645",
"0.6538199",
"0.6529562",
"0.65264386",
"0.65136915",
"0.65116817",
"0.64828026",
"0.6473997",
"0.645265",
"0.6447258",
"0.64272326",
"0.64080304",
"0.6401684",
"0.63976383",
"0.6396956",
"0.639669",
"0.639669",
"0.6370008",
"0.63622695",
"0.6321079",
"0.630383",
"0.630042",
"0.6299421",
"0.627889",
"0.6269164",
"0.6256335",
"0.6246953",
"0.621691",
"0.6215751",
"0.6209112",
"0.62041736",
"0.6190293",
"0.6190184",
"0.61806774",
"0.6174891",
"0.61559",
"0.61527544",
"0.6148821",
"0.6137709",
"0.61313635",
"0.6125351",
"0.6123668",
"0.61213017",
"0.61156744",
"0.6110375",
"0.61051095",
"0.6086332",
"0.60839957",
"0.6073924",
"0.60644406",
"0.60628766",
"0.60513276",
"0.60513234",
"0.6049825",
"0.60441715",
"0.6037897",
"0.6036028",
"0.6035469",
"0.6031079",
"0.60261863",
"0.60226876",
"0.6015092",
"0.6007399",
"0.60063773",
"0.6005155",
"0.598769",
"0.59751153",
"0.5973459",
"0.59723735",
"0.5967697",
"0.5961212",
"0.5955374",
"0.5953916",
"0.59533745",
"0.5952975",
"0.5939767"
] |
0.7037308
|
4
|
Test the remove_from_parent! method.
|
def test_remove_from_parent_bang
setup_test_tree
assert(@root.has_children?, "Should have children")
assert(!@root.is_leaf?, "Root is not a leaf here")
child1 = @root[0]
assert_not_nil(child1, "Child 1 should exist")
assert_same(@root, child1.root, "Child 1's root should be ROOT")
assert(@root.include?(child1), "root should have child1")
child1.remove_from_parent!
assert_same(child1, child1.root, "Child 1's root should be self")
assert(!@root.include?(child1), "root should not have child1")
child1.remove_from_parent!
assert_same(child1, child1.root, "Child 1's root should still be self")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def removeFromParent\n @parent.remove(self) if @parent\n end",
"def remove_parent\n # has to go from parent to child\n self.parent.remove_child(self)\n end",
"def remove_parent(selector); end",
"def remove_from_parent\n @change_set = ChangeSet.for(resource)\n parent_resource = find_resource(parent_resource_params[:id])\n authorize! :update, parent_resource\n\n parent_change_set = ChangeSet.for(parent_resource)\n current_member_ids = parent_resource.member_ids\n parent_change_set.member_ids = current_member_ids - [resource.id]\n\n obj = nil\n change_set_persister.buffer_into_index do |persist|\n obj = persist.save(change_set: parent_change_set)\n end\n after_update_success(obj, @change_set)\n rescue Valkyrie::Persistence::ObjectNotFoundError => e\n after_update_error e\n end",
"def remove_parent(parent)\n ActsAsDAG::HelperMethods.unlink(parent, self)\n return parent\n end",
"def remove_item\n @parent.remove_item(self)\n end",
"def move_from_old_parent\n parent.remove(self)\n end",
"def remove_parent_object(parent, relation = nil)\n\t parent.remove_child_object(self, relation)\n\tend",
"def unregister_parent( *args )\n \n @parent = nil\n\n return self\n \n end",
"def test_check_before_destroy(parent, child)\n # Ensure that can destroy parent without child\n @parent = Factory(parent)\n lambda do\n @parent.destroy\n end.should change(parent.to_s.camelcase.constantize, :count).by(-1)\n \n @parent = Factory(parent)\n # Stub so that it appears @parent does have child records.\n @parent.stub(child.to_s.pluralize).and_return([1])\n @parent.stub(child).and_return([1])\n lambda do\n @parent.destroy\n end.should_not change(parent.to_s.camelcase.constantize, :count)\n end",
"def remove_act\n # select rep_parent if it exists\n node = self\n if !self.rep_parent.nil?\n node = self.rep_parent\n end\n\n # outdent children in case remove_act doesn't delete\n node.children.each do |child|\n child.outdent\n child.remove_act\n end\n\n # hold parent in case it need be updated\n old_parent = node.parent\n \n node.repititions.destroy_all\n node.destroy\n\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def detach_from_parent\n return nil if parent.nil? # root\n oci = own_child_index\n parent.children.delete_at(oci) if oci\n self.parent = nil\n oci\n end",
"def perform_remove_parent(batch_client, parent_id)\n self.class.make_request(client, batch_client, :remove_parent, scope_parameters.merge(\n self.class.primary_key_name => primary_key,\n parent_id: parent_id\n ))\n end",
"def remove\n each { |x| x.parent.children.delete(x) }\n end",
"def delete!\n if parent\n parent.remove_child(id)\n @parent = nil\n end\n collection.remove(_id: id)\n self.id = nil\n true\n end",
"def test_nested_collection_destroy\n old_child = @parent.children.first\n childcontroller = ChildController.new(params: { id: old_child.id })\n childcontroller.invoke(:destroy)\n\n assert_equal(200, childcontroller.status, childcontroller.hash_response)\n\n @parent.reload\n\n assert_equal(%w[c2], @parent.children.order(:position).pluck(:name))\n assert_predicate(Child.where(id: old_child.id), :empty?)\n end",
"def assign_to_parent(element)\n element.remove!\n element.parent = parent\n end",
"def remove_child(node)\n if node.parent == nil\n raise \"this is an orphan\"\n end \n node.parent = nil\n end",
"def remove_relationship_above\n authorize! :edit, form_params[:parent_id]\n if form.remove\n notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)\n redirect_to redirect_path(item: form.child), notice: notice\n else\n redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }\n end\n end",
"def node_leave_parent(node, parent)\n node.parents.delete(parent)\n end",
"def remove_from_parent\n @__context__.executor << FlowFiber.new { @parent.remove(self) }\n end",
"def remove_from_tree(item, node) \n return rebalance(super(item, node))\n end",
"def remove_relationship_under\n authorize! :edit, form_params[:parent_id]\n\n if form.remove\n notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)\n redirect_to redirect_path(item: form.parent), notice: notice\n else\n redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }\n end\n end",
"def removing_plan_relation(transaction, parent, child, relations); end",
"def delete_with_no_child(parent, direction)\n parent.send \"#{direction}=\".to_sym, nil\n end",
"def has_parent!(parent)\n @parent = parent\n self\n end",
"def remove_parent(parent_id = nil)\n response = perform_remove_parent(nil, parent_id)\n reload!\n end",
"def clear\n @parent = nil\n end",
"def parent=(new_parent)\n if parent != new_parent\n p = position\n remove_from_list if (p && valid?)\n super\n add_to_list_bottom if (p && valid?)\n else\n super\n end\n end",
"def remove_child(component)\n @children.delete(component)\n component.parent = nil\n end",
"def detach parent\n\n # the ordinary *able table\n parent.send( self.class.to_s.underscore.pluralize).delete self\n\n # case child.class.to_s\n # when \"Event\",\"WageEvent\"\n # ev = Eventable.where( event: child, eventable: self)\n # ev.delete_all\n # when \"Printer\"\n # pr = Printable.where( printer: child, printable: self)\n # pr.delete_all\n # else\n # children = eval child.class.to_s.downcase.pluralize\n # children.delete child\n # end\n rescue\n false\n end",
"def remove_from_parents\n ordered_by.each do |parent|\n parent.ordered_members.delete(self) # Delete the list node\n parent.members.delete(self) # Delete the indirect container Proxy\n parent.save! # record the changes to the ordered members\n end\n end",
"def batch_remove_parent(batch_client, parent_id = nil)\n perform_remove_parent(batch_client, parent_id)\n end",
"def remove(component)\n \t@children.delete(component)\n \tcomponent.parent = nil\n end",
"def move_under new_parent\n ensure_exists!\n ensure_no_cycle! new_parent\n if parent\n parent.remove_child self\n else\n trace.remove_root self\n end\n if new_parent\n new_parent.add_child self\n @parent_span_id = new_parent.span_id\n else\n trace.add_root self\n @parent_span_id = 0\n end\n @parent = new_parent\n self\n end",
"def remove_act\n # outdent children in case remove_act doesn't delete\n self.children.each do |child|\n child.outdent\n child.remove_act\n end\n \n # check if parent should update completeness\n old_parent = self.parent\n\n self.permissions.destroy_all\n self.destroy\n \n # refresh parent completeness\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def test_hc_noderemovechild\n doc = nil\n rootNode = nil\n childList = nil\n childToRemove = nil\n removedChild = nil\n parentNode = nil\n doc = load_document(\"hc_staff\", true)\n rootNode = doc.documentElement()\n childList = rootNode.childNodes()\n childToRemove = childList.item(1)\n removedChild = rootNode.removeChild(childToRemove)\n parentNode = removedChild.parentNode()\n assert_nil(parentNode, \"parentNodeNull\")\n \n end",
"def remove_child(child_node) \n unless children.include?(child_node) \n raise \"This child does not exist\" \n else \n child_node.parent = nil \n end \n end",
"def parent=(new_parent) \n parent.children.delete(self) if @parent #=> this is the old parent removing the child that is being adopted \n @parent = new_parent #=> I have a new mommy! \n new_parent.children << self unless @parent == nil || new_parent.children.include?(self) \n end",
"def child_pre_delete_hook( index, parent_array = nil )\n \n # false means delete does not take place\n return true\n \n end",
"def prune!\n return if root? #you cannot prune the root\n if normal?\n parent.normal_children.delete(self)\n else\n parent.fallback_child = nil\n end\n old_parent = parent\n @parent = nil\n old_parent.prune! if old_parent.useless?\n end",
"def move!\r\n return unless create_new_parent?\r\n parent_arg = find_new_parent\r\n self.move_to_child_of(parent_arg)\r\n if parent_arg\r\n self.debate_id = parent_arg.debate_id\r\n self.children.update_all(\"debate_id = #{parent_arg.debate_id}\")\r\n end\r\n end",
"def perform_some_actions\n # It is to be called while destroying a Child record\n # But must not be called while destroying the parent record\n unless self.parent.destroyed?\n\n end\n end",
"def reply_to_parent (exp, workitem, remove=true)\n\n workitem.last_expression_id = exp.fei\n\n onotify(:reply_to_parent, exp, workitem)\n\n if remove\n\n remove(exp)\n #\n # remove the expression itself\n\n exp.clean_children\n #\n # remove all the children of the expression\n end\n\n #\n # manage tag, have to remove it so it can get 'redone' or 'undone'\n # (preventing abuse)\n #\n # do the same for the on_error handler if any\n\n tagname = exp.attributes['tag']\n exp.delete_variable(tagname) if tagname\n #exp.delete_variable(tagname) if tagname and not tagname.match(/^\\//)\n\n on_error = exp.attributes['on_error'] #if exp.attributes\n exp.delete_variable(on_error) if on_error\n\n #\n # has raw_expression been updated ?\n\n track_child_raw_representation(exp)\n\n #\n # flow terminated ?\n\n if (not exp.parent_id) and (exp.fei.expid == '0')\n\n ldebug { \"reply_to_parent() process #{exp.fei.wfid} terminated\" }\n\n onotify(:terminate, exp, workitem)\n\n return\n end\n\n #\n # else, gone parent ?\n\n #if (not exp.parent_id) or (exp.parent_id.expname == 'gone')\n # # this 'gone' is kept for some level of 'backward compatibility'\n\n if (not exp.parent_id)\n\n ldebug { \"reply_to_parent() parent is gone for #{exp.fei.to_debug_s}\"}\n return\n end\n\n #\n # parent still present, reply to it\n\n reply(exp.parent_id, workitem)\n end",
"def link_to_remove_parent\n image = image_tag(\"cross_small.png\", :border => 0, :alt => \"#{ _(\"Remove\") }\")\n link_to_function(image, 'jQuery(this).parent().remove();')\n end",
"def remove(child)\n# if children.delete(child)\n# scene.unindex_prop(child) if scene\n @peer.remove(child.peer)\n# end\n end",
"def destroy\n #primitives in structs are without parent\n parent and parent.children.delete self\n end",
"def set_parent(new_parent)\n if new_parent.is_a? Activity\n old_parent = self.parent\n new_parent.children << self # add to new parent\n self.parent = new_parent\n self.is_root = false\n self.save!\n new_parent.is_complete? # update new_parent completeness\n \n # remove from old parent\n if old_parent != nil\n old_parent.children.delete(self)\n old_parent.is_complete? # in case depends on \n end\n \n return true\n else\n\n return false\n end\n end",
"def set_parent!(p)\n unless p.nil? || p.is_a?(Warehouse)\n if p.to_s.blank?\n p = nil\n else\n p = Warehouse.find_by_id(p)\n return false unless p\n end\n end\n if p == parent && !p.nil?\n # Nothing to do\n true\n elsif p.nil? || (p.active? && move_possible?(p))\n # Insert the project so that target's children or root projects stay alphabetically sorted\n sibs = (p.nil? ? self.class.roots : p.children)\n to_be_inserted_before = sibs.detect {|c| c.name.to_s.downcase > name.to_s.downcase }\n if to_be_inserted_before\n move_to_left_of(to_be_inserted_before)\n elsif p.nil?\n if sibs.empty?\n # move_to_root adds the project in first (ie. left) position\n move_to_root\n else\n move_to_right_of(sibs.last) unless self == sibs.last\n end\n else\n # move_to_child_of adds the project in last (ie.right) position\n move_to_child_of(p)\n end\n #Issue.update_versions_from_hierarchy_change(self)\n true\n else\n # Can not move to the given target\n false\n end\n end",
"def remove(node)\n if node.parent.nil?\n @root = nil\n return\n end\n if node.parent.left == node\n node.parent.left = nil\n elsif node.parent.right == node\n node.parent.right = nil\n end\n end",
"def move_to_child_of(category)\n self.update_attribute(:parent_id, category.id) unless self.parent_id == category.id\n end",
"def test_remove_bang\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove!(@child1)\n assert_equal(2, @root.size, \"Should have two nodes\")\n @root.remove!(@child2)\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n # Some negative testing\n @root.remove!(nil)\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_parent\n setup_test_tree\n\n assert_nil(@root.parent, \"Root's parent should be nil\")\n assert_equal(@root, @child1.parent, \"Parent should be root\")\n assert_equal(@root, @child3.parent, \"Parent should be root\")\n assert_equal(@child3, @child4.parent, \"Parent should be child3\")\n assert_equal(@root, @child4.parent.parent, \"Parent should be root\")\n end",
"def parent=(a_parent)\n if parent \n parent.children.delete(self)\n end \n \n if a_parent.nil? \n @parent = a_parent\n return\n else\n a_parent.children << self unless a_parent.children.include?(self)\n @parent = a_parent\n end \n end",
"def remove_child(le)\n\t\t\t@children.delete le\n\t\t\tle.parent = nil\n\t\tend",
"def orphan\n parent.disown self if parent\n @parent = nil\n end",
"def update_collection_parent\n old_parent = @collection.parent\n old_parent.delete_member_by_id(@collection.id)\n old_parent.save\n\n new_parent = find_new_parent\n new_parent.member_ids = [@collection.id] + new_parent.member_ids\n new_parent.save\n end",
"def remove_before(node, stop_node)\n # Stopping condition\n return if node == stop_node\n\n # Get parent\n parent = node.parent\n\n # Get siblings\n siblings = parent.children\n\n # Get node's index\n index = siblings.index(node)\n\n # Remove siblings before node\n parent.children = siblings.slice(index..-1)\n\n # Remove nodes after the parent\n remove_before(parent, stop_node)\n end",
"def test_nested_collection_replace\n # Parent.children\n old_children = @parent.children\n\n data = [{ '_type' => 'Child', 'name' => 'newc1' },\n { '_type' => 'Child', 'name' => 'newc2' },]\n\n childcontroller = ChildController.new(params: {\n owner_viewmodel: 'parent',\n association_name: 'children',\n parent_id: @parent.id,\n data: data,\n })\n childcontroller.invoke(:replace)\n\n assert_equal(200, childcontroller.status, childcontroller.hash_response)\n\n @parent.reload\n\n assert_equal(%w[newc1 newc2], @parent.children.order(:position).pluck(:name))\n assert_predicate(Child.where(id: old_children.map(&:id)), :empty?)\n\n assert_all_hooks_nested_inside_parent_hook(childcontroller.hook_trace)\n end",
"def destroy\n @parent_of.destroy\n respond_to do |format|\n format.html { redirect_to parent_ofs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent = nil\n @root = nil\n end",
"def get_parent_object\n nil\n end",
"def reply_to_parent(workitem)\n\n @context.tracker.remove_tracker(h.fei)\n\n super(workitem)\n end",
"def delete_relationship_of_parent_with_child(parent_ou_id, child_ou_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{child_ou_id}/parents/#{parent_ou_id}\"\n _delete(path)\nend",
"def unregister_parent( parent_array )\n \n if @parents.delete( parent_array )\n parent_array.reverse_each_range do |this_object, this_parent_index|\n update_for_parent_delete_at( parent_array, this_parent_index, this_object )\n end\n @cascade_controller.unregister_parent( parent_array )\n parent_array.unregister_child( self )\n end\n \n return self\n \n end",
"def teardown\n @root.remove!(@left_child1)\n @root.remove!(@right_child1)\n @root = nil\n end",
"def remove_parent_if_empty_string\n self[:parent_id] = nil if self[:parent_id] == \"\"\n end",
"def child_tree\n child_check\n child_tree = self.clone\n child_tree.removeFromParent!\n child_tree\n end",
"def child_pre_delete_hook( key, parent_hash = nil )\n \n # false means delete does not take place\n return true\n \n end",
"def set_parent(new_parent)\n if new_parent.is_a? Activity\n old_parent = self.parent\n if !self.rep_parent.nil?\n return self.rep_parent.set_parent(new_parent)\n end\n new_parent.children << self # add to children\n self.parent_id = new_parent.id\n self.is_root = false\n self.save!\n new_parent.is_complete?\n \n if old_parent != nil\n old_parent.children.delete(self)# delete from old parent\n old_parent.is_complete? # in case depends on \n end\n return true\n else\n return false\n end\n end",
"def move_to(new_parent)\n self.parent = new_parent.is_a?(String) ?\n find!(new_parent) : new_parent\n end",
"def ignore_parent_exclusion?; end",
"def test_movie_valid_parent\n movie = Movie.find( movies(:king_kong).id )\n parent = Movie.find( movies(:batman_series).id )\n movie.parent = parent\n assert movie.save\n assert_equal( 2, parent.children.size )\n end",
"def delete_relationship_of_child_with_parent(parent_ou_id, child_ou_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{parent_ou_id}/children/#{child_ou_id}\"\n _delete(path)\nend",
"def destroy_ancestors\n parent = self.parent\n self.destroy\n if parent and parent.children.first.blank?\n parent.destroy_ancestors\n end\n end",
"def delete_node(current_node)\n\nend",
"def replace_parent( *args )\n \n new_parent = nil\n existing_parent = nil\n \n case args.size\n when 1\n new_parent = args[ 0 ]\n when 2\n # existing_parent = args[ 0 ]\n new_parent = args[ 1 ]\n end\n \n unregister_parent\n register_parent( new_parent )\n\n return self\n \n end",
"def ignore_parent_exclusion; end",
"def remove_child child\n @children.delete child\n end",
"def remove_act\n # outdent children in case remove_act doesn't delete\n self.children.each do |child|\n if child.type != 'GoalTracker'\n child.outdent\n child.remove_act\n end\n end\n \n # check if parent should update completeness\n old_parent = self.parent\n\n self.state = Activity::ABANDONED\n self.save!\n \n # refresh parent completeness\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def parent=(parent_node); end",
"def parent=(parent_node); end",
"def test_job_association_after_parent_delete\n Job.create(:batch => Batch.find(2), :tiff_number => 123, :check_number => 121313, :count => 12, :estimated_eob => 12)\n first_count=Job.count(:batch_id, :conditions => [\"batch_id = ?\", 2])\n Batch.destroy(2)\n second_count=Job.count(:batch_id, :conditions => [\"batch_id = ?\", 2])\n assert_not_equal(first_count,second_count)\n end",
"def parent=(other); end",
"def delete_child(product)\r\n\t\tproduct = product.is_a?(Product) ? product.id : product.to_i\r\n\t\tcomponents.delete(components.find_by_child_id(product))\r\n\tend",
"def test_remove_fish_from_river\n assert_equal(1, @river.remove_from_river(@fish_1))\n end",
"def update_for_parent_delete_at( parent_array, parent_index, object )\n\n did_delete = false\n\n if @cascade_controller.parent_controls_parent_index?( parent_array, parent_index )\n\n local_index = @cascade_controller.local_index( parent_array, parent_index )\n \n if @without_child_hooks || child_pre_delete_hook( local_index, parent_array )\n\n @cascade_controller.parent_delete_at( parent_array, parent_index )\n\n # I'm unclear why if we call perform_delete_between_hooks (including through non_cascading_delete_at)\n # we end up smashing the last index's lazy lookup value, turning it false\n # for now simply adding hooks manually here works; the only loss is a little duplicate code\n # to call the local (non-child) hooks\n if @without_hooks || pre_delete_hook( local_index )\n did_delete = true\n object = undecorated_delete_at( local_index )\n object = post_delete_hook( local_index, object ) unless @without_hooks\n child_post_delete_hook( local_index, object, parent_array ) unless @without_child_hooks\n @children.each { |this_array| this_array.update_for_parent_delete_at( self, local_index, object ) }\n end\n \n else\n\n if @cascade_controller.requires_lookup?( local_index )\n lazy_set_parent_element_in_self( local_index, object, true )\n end\n \n end\n \n end\n\n return did_delete\n \n end",
"def hand_off_to!(other)\n verify_hand_off_to(other)\n other.children.replace children\n other.parent = parent\n @children = EmptyClass\n @parent = nil\n end",
"def child_post_delete_hook( index, object, parent_array = nil )\n \n return object\n \n end",
"def after_create_save(record)\n record.move_to_child_of record.parent.id unless record.parent.nil?\n end",
"def test_movie_invalid_parent\n movie = Movie.find( movies(:king_kong).id )\n parent = Movie.find( movies(:lili_marleen).id )\n movie.parent = parent\n assert !movie.valid?\n# assert !movie.save\n end",
"def remove(node)\n end",
"def remove_child(child)\n if @children.delete(child)\n child.parent = nil\n end\n end",
"def test_remove_at_position_2\n @linked_list.remove_at_position(2)\n assert_equal [1,2,4,5,6], @linked_list.traverse\n end",
"def remove_node\n remove_node_helper(@root)\n end",
"def delete(object_or_id)\n\t\t\t\t\tobject = case object_or_id\n\t\t\t\t\twhen String, Moped::BSON::ObjectId\n\t\t\t\t\t\t@parent.class.find object_or_id\n\t\t\t\t\telse\n\t\t\t\t\t\tobject_or_id\n\t\t\t\t\tend\n\n\t\t\t\t\tobject.write_attribute object.parent_id_field, nil\n\t\t\t\t\tobject[object.path_field] = []\n\t\t\t\t\tobject[object.depth_field] = 0\n\t\t\t\t\tobject.save\n\n\t\t\t\t\tsuper(object)\n\t\t\t\tend",
"def ensure_parent_message\n self.parent_message = self if self.parent_message.nil?\n end",
"def _parent; end",
"def delete\n if self.father\n if self.is_left_son?\n self.father.copy(self.father.right_sentence)\n elsif self.is_right_son?\n self.father.copy(self.father.left_sentence)\n end\n aux = self.father\n while aux != nil\n aux.update\n aux = aux.father\n end\n return true\n else\n return false\n end\n end",
"def parent_delete_at( parent_array, parent_index, \n parent_local_map = parent_local_map( parent_array ), \n local_parent_map = local_parent_map( parent_array ) )\n \n local_index = nil\n\n if parent_controls_parent_index?( parent_array, parent_index, parent_local_map, local_parent_map )\n local_index = parent_local_map.delete_at( parent_index )\n @requires_lookup.delete_at( local_index )\n @local_index_to_parent_map.delete_at( local_index )\n local_parent_map.delete_at( local_index )\n renumber_local_indexes_for_delete( local_index )\n else\n local_index = parent_local_map.delete_at( parent_index )\n end\n\n # renumber any indexes in local to parent map where parent > parent_index\n local_parent_map.renumber_mapped_indexes_for_delete( parent_index )\n\n return local_index\n \n end"
] |
[
"0.7715611",
"0.7382604",
"0.7307142",
"0.68450654",
"0.68401265",
"0.6837654",
"0.6741294",
"0.66547126",
"0.6604148",
"0.6529854",
"0.6482111",
"0.6477159",
"0.64689726",
"0.6445911",
"0.64372575",
"0.63909924",
"0.63823104",
"0.6352334",
"0.63177717",
"0.6310191",
"0.6235661",
"0.6172169",
"0.6154974",
"0.6140462",
"0.6133063",
"0.6126021",
"0.61257356",
"0.61170757",
"0.61148125",
"0.6109949",
"0.6103259",
"0.60864884",
"0.6055368",
"0.6042658",
"0.6039522",
"0.60272974",
"0.60160655",
"0.6000958",
"0.5970201",
"0.5967085",
"0.5952431",
"0.5917071",
"0.59147847",
"0.59065473",
"0.5898352",
"0.58843064",
"0.58749354",
"0.5853515",
"0.5843016",
"0.5835142",
"0.58320576",
"0.5828323",
"0.5802032",
"0.57957584",
"0.5777089",
"0.57768565",
"0.5765072",
"0.5749068",
"0.5734573",
"0.5732988",
"0.5726524",
"0.5708423",
"0.5683961",
"0.56816083",
"0.56793857",
"0.56766665",
"0.5675295",
"0.56688696",
"0.5657162",
"0.56455094",
"0.56413454",
"0.5635382",
"0.5633424",
"0.5621758",
"0.56117904",
"0.5608547",
"0.55976456",
"0.55942374",
"0.55935496",
"0.55927736",
"0.55846524",
"0.55846524",
"0.5577361",
"0.55709904",
"0.5570261",
"0.5568526",
"0.5556187",
"0.5554084",
"0.5552271",
"0.555203",
"0.5551496",
"0.5540039",
"0.55383694",
"0.55373037",
"0.5535275",
"0.55276036",
"0.5524259",
"0.5504733",
"0.5487429",
"0.54848015"
] |
0.7794357
|
0
|
Test the children method.
|
def test_children
setup_test_tree
assert(@root.has_children?, "Should have children")
assert_equal(5, @root.size, "Should have five nodes")
assert(@child3.has_children?, "Should have children")
assert(!@child3.is_leaf?, "Should not be a leaf")
assert_equal(1, @child3.node_height, "The subtree at Child 3 should have a height of 1")
for child in [@child1, @child2, @child4]
assert_equal(0, child.node_height, "The subtree at #{child.name} should have a height of 0")
end
children = []
for child in @root.children
children << child
end
assert_equal(3, children.length, "Should have three direct children")
assert(!children.include?(@root), "Should not have root")
assert(children.include?(@child1), "Should have child 1")
assert(children.include?(@child2), "Should have child 2")
assert(children.include?(@child3), "Should have child 3")
assert(!children.include?(@child4), "Should not have child 4")
children.clear
children = @root.children
assert_equal(3, children.length, "Should have three children")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children\n raise NotImplementedError\n end",
"def children\n child_check\n super\n end",
"def display_parent_child_test_cases\n \n end",
"def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end",
"def _children\n expected_amount == 1 ? 'child' : 'children'\n end",
"def each_child\n \n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def get_children\n \t@children\n end",
"def children\n self.class.children(self) \n end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def _children\n @children\n end",
"def children\n _children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def children\n examples + steps + tags\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def getChildren\n begin\n elementObject = waitForObject(@symbolicName, OBJECT_WAIT_TIMEOUT)\n children = Squish::Object.children(elementObject)\n return children\n rescue Exception => e\n\t Log.TestFail(\"#{self.class.name}::#{__method__}(): Failed to get children for #{@name}: #{e.message}\")\n return nil\n end\n end",
"def get_children\n @children\n end",
"def apply_children\n \n end",
"def children\n steps\n end",
"def children?\n !@children.empty?\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def children\n NotImplemented\n end",
"def children\n NotImplemented\n end",
"def has_children(child_types)\n @child_types = child_types\n\n define_method_child_types\n define_method_children\n define_method_accepts\n end",
"def children() []; end",
"def children_exist?\n\tend",
"def find_children(method, *args)\n children.select do |child_klass|\n child_klass.send(method, *args)\n end\n end",
"def children?\n\t\t\t@children && !@children.empty?\n\t\tend",
"def children_get()\n @children\n end",
"def children?\n\t\t\treturn children.size > 0\n\t\tend",
"def children?\n !children.empty?\n end",
"def children?\n !children.empty?\n end",
"def children?\n !children.empty?\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end",
"def children\n []\n end",
"def get_children\n return children\n end",
"def children\n []\n end",
"def children\n child_objects(Dependency)\n end",
"def children?\n\t\t\t@children.size > 0 ? true : false\n\t\tend",
"def children?\n return false if @children.length == 0\n end",
"def children; []; end",
"def evaluate_children(mode)\n children.collect { |c| c.evaluate mode }\n end",
"def have_children?\n children.count != 0\n end",
"def children\n models = tests + tags\n models << background if background\n\n models\n end",
"def each_child\n @children.each { |child| yield child }\n end",
"def each\n @children.each {|child| yield child}\n end",
"def child_condition; end",
"def children_with_results\n children.select(&:any_results_including_children?)\n end",
"def children\n properties \n end",
"def children\n []\n end",
"def children\n []\n end",
"def check_children\n # We take care of our children. If someone kill one, me made another one.\n # PS: Is a hard work :P\n loop do\n pid = Process.wait\n @child_pids.delete(pid)\n @child_pids << spawn_child\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children?\n @contents.children?\n end",
"def child_of?(parent); end",
"def children?\n self.children.any?\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def has_children?\n false\n end",
"def parse_children\n worked = false\n worked = true while parse_element or parse_comment or parse_cdata or parse_data\n worked\n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def each_child\n @children.each { |child| yield child }\n end",
"def allowed_children; end",
"def child?\n true\n end",
"def children\n @root.children & @initial_contents\n end",
"def children\n if no_child?\n []\n else\n [ body ]\n end\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def all_child_text\n abstract_method\n end",
"def process_child_nodes(node); end",
"def test_children\n #puts \"---------------test_children-----------------\"\n t= {}\n\n batch11 = MyResource.new :batch11\n batch12 = MyResource.new :batch12\n batch21 = MyResource.new :batch21\n batch22 = MyResource.new :batch22\n pos1 = MyResource.new :pos1, [ batch11, batch12 ]\n pos2 = MyResource.new :pos2, [ batch21, batch22 ]\n order = MyResource.new :order, [pos1, pos2]\n\n GraphBuilder::Builder.build do |b|\n t[:order] = [ b.add(Thing0.new(order)) ]\n \n b.children do |pos|\n t[pos.name] = b.add Thing1.new(pos)\n b.children do |batch|\n b1 = b.add Thing11.new(batch)\n b2 = b.add Thing12.new(batch)\n t[batch.name] = [b1, b2]\n end\n end\n t[:order] << b.add( Thing2.new(order))\n end\n\n r = Thing.links(t.values.flatten)\n assert_instance_of Thing0, t[:order].first\n assert_instance_of Thing2, t[:order].last\n assert_instance_of Thing1, t[:pos1]\n assert_instance_of Thing1, t[:pos2]\n assert_instance_of Thing11, t[:batch11].first\n assert_instance_of Thing12, t[:batch12].last\n assert_instance_of Thing11, t[:batch21].first\n assert_instance_of Thing12, t[:batch22].last\n\n assert r.include? [t[:order].first,t[:pos1]]\n assert r.include? [t[:order].first,t[:pos2]]\n assert r.include? [t[:pos1],t[:batch11].first]\n assert r.include? [t[:pos1],t[:batch12].first]\n assert r.include? [t[:pos2],t[:batch21].first]\n assert r.include? [t[:pos2],t[:batch22].first]\n assert r.include? [t[:batch11].first,t[:batch11].last]\n assert r.include? [t[:batch12].first,t[:batch12].last]\n assert r.include? [t[:batch21].first,t[:batch21].last]\n assert r.include? [t[:batch22].first,t[:batch22].last]\n assert r.include? [t[:batch11].last,t[:order].last]\n assert r.include? [t[:batch12].last,t[:order].last]\n assert r.include? [t[:batch21].last,t[:order].last]\n assert r.include? [t[:batch22].last,t[:order].last]\n\n assert_equal 14, r.size\n end",
"def get_children\n return @children\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def children\n @children ||= []\n end"
] |
[
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.7388832",
"0.71020573",
"0.7087898",
"0.68895894",
"0.68776155",
"0.6828522",
"0.67999005",
"0.67268866",
"0.66181093",
"0.66004515",
"0.6579364",
"0.6567658",
"0.6567658",
"0.6504818",
"0.64970857",
"0.64952374",
"0.6488152",
"0.6488152",
"0.6488152",
"0.6488152",
"0.6486396",
"0.6468342",
"0.6455567",
"0.64427906",
"0.6417317",
"0.6394166",
"0.6383135",
"0.6367863",
"0.6367863",
"0.63613385",
"0.63613385",
"0.636098",
"0.63308424",
"0.6321957",
"0.6287811",
"0.62631273",
"0.62478334",
"0.6220091",
"0.6168447",
"0.6164843",
"0.6164843",
"0.6163133",
"0.6161339",
"0.6160751",
"0.61446077",
"0.6144419",
"0.6138179",
"0.6125843",
"0.6122098",
"0.611953",
"0.6098254",
"0.6093439",
"0.60913295",
"0.60873187",
"0.60773766",
"0.606428",
"0.6060382",
"0.6057944",
"0.60405654",
"0.6028434",
"0.6028434",
"0.6027429",
"0.60259444",
"0.60254115",
"0.60254115",
"0.60254115",
"0.60238403",
"0.6022416",
"0.6019496",
"0.60182625",
"0.6007954",
"0.5989905",
"0.59882194",
"0.59882194",
"0.59882194",
"0.59882194",
"0.59872913",
"0.59855",
"0.5984705",
"0.5978299",
"0.5975215",
"0.5960685",
"0.5960685",
"0.5959239",
"0.5958397",
"0.59552497",
"0.5949657",
"0.5940813",
"0.593853"
] |
0.7104079
|
12
|
Test the first_child method.
|
def test_first_child
setup_test_tree
assert_equal(@child1, @root.first_child, "Root's first child is Child1")
assert_nil(@child1.first_child, "Child1 does not have any children")
assert_equal(@child4, @child3.first_child, "Child3's first child is Child4")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n assert_same(@child1, @child2.first_sibling, \"Child2's first sibling should be child1\")\n assert_same(@child1, @child3.first_sibling, \"Child3's first sibling should be child1\")\n assert_same(@child4, @child4.first_sibling, \"Child4's first sibling should be itself\")\n assert_not_same(@child1, @child4.first_sibling, \"Child4's first sibling is itself\")\n end",
"def first_child\n child 0\n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def first *a; self.child(*a) + ':first-child' end",
"def first\n @children[0]\n end",
"def first_child\n children.min_by { |x| x.position}\n end",
"def first_child?\n if mother = participant.try(:mother)\n if mother.participant?\n return mother.children.first == self\n end\n end\n false\n end",
"def first_element_child\n n = self.first_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end",
"def have_first_child!\n @children << random_sex_baby\n end",
"def is_first_child?(question)\n answer_for(question, participant.person.is_first_child?)\n end",
"def second_child\n child 1\n end",
"def name\n return nil unless children?\n return nil unless first_child.children?\n first_child.first_child\n end",
"def first_item\n @children[@items.first]\n end",
"def leftChild\r\n children.first\r\n end",
"def first(path_stack, node); end",
"def first\n end",
"def function\n children[0]\n end",
"def first_sibling\n node = self\n while node.previous_sibling\n node = node.previous_sibling\n end\n return node\n end",
"def first!\n fail_not_found_if_nil(first)\n end",
"def test_next_sibling\n setup_test_tree\n\n assert_nil(@root.next_sibling, \"Root does not have any next sibling\")\n assert_equal(@child2, @child1.next_sibling, \"Child1's next sibling is Child2\")\n assert_equal(@child3, @child2.next_sibling, \"Child2's next sibling is Child3\")\n assert_nil(@child3.next_sibling, \"Child3 does not have a next sibling\")\n assert_nil(@child4.next_sibling, \"Child4 does not have a next sibling\")\n end",
"def first; end",
"def first; end",
"def first_sibling_in_list\n self.class.asc(:position).first\n end",
"def first() end",
"def first?\n self.rel == \"first\"\n end",
"def first_node_name\n first_child = @fragment.children.first\n (first_child && first_child.respond_to?(:name)) ? first_child.name : nil\n end",
"def node_first\n @head\n end",
"def first?; end",
"def self_or_first_descendant\n block = self\n while block.descendant; block = block.descendant; end\n block\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def test_using_first_of\n @filelist = nil\n sublist = first_of( self.filelist ) \n results = test_using_sublist( sublist )\n output.puts \"Test Using First Of\".center(72)\n output.puts \"=\" * 72\n report_results( results )\n end",
"def has_one_child\n if self.left_child.nil? && !self.right_child.nil?\n self.right_child\n elsif !self.left_child.nil? && self.right_child.nil?\n self.left_child\n else\n nil\n end\n end",
"def test_first_node_is_root_node\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n assert_equal \"movie a\", tree.root.title\n end",
"def test_first_object\n assert_kind_of Member, members(:first_programmer)\n assert_equal \"First\", members(:first_programmer).first_name\n end",
"def first_item?\n true\n end",
"def child\n children[0]\n end",
"def first?\n not first.nil?\n end",
"def test_first_name_is_required\n assert !children(:first_name_missing).valid?\n assert children(:first_name_missing).errors.on(:first_name)\n end",
"def first_child\n self.at('/RETS/RETS-RESPONSE') or self.at('/RETS')\n end",
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def expand_first_row\n @tree.expand_first_row\n end",
"def min_child(index)\n ch_e = (index + 1) * 2\n ch_o = (index * 2) + 1\n\n if @nodes[ch_e] && @nodes[ch_o]\n @compare_fn[@nodes[ch_e][:value], @nodes[ch_o][:value]] ? ch_e : ch_o\n elsif @nodes[ch_e]\n ch_e\n elsif @nodes[ch_o]\n ch_o\n else\n nil\n end\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def dom_class_first(object, array)\n if (object == array.first)\n return \"first\"\n end\n nil\n end",
"def test_0680_first\n @@log.debug \"test_0680_first starts\" if @@log.debug?\n assert_respond_to(@list, :first, \"test_0680_first_respond\")\n # Get first item only\n result = @list.first\n assert_equal(result, @aen, \"test_0680_first_one\")\n # Get first two items\n result = @list.first(2)\n assert_equal(result, [@aen,@bsb], \"test_0680_first_two\")\n @@log.debug \"test_0680_first ends\" if @@log.debug?\n end",
"def first\n\t\traise \"ContainerEmpty\" if @head.nil?\n\t\t@head\n\tend",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def first_sibling(scope = {})\n self_and_siblings(scope.merge(:limit => 1, :order => \"#{prefixed_left_col_name} ASC\")).first\n end",
"def first_part\n self.parsed_page ||= @connect.page self.name\n self.parsed_page.search(\"p\").first.children.first\n end",
"def depth_first(node, target)\n if node.children\n node.children.each do |child|\n depth_first(child, target)\n end\n end\n return 'Found your target' if node.payload == target\n 'No luck'\nend",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def first?\n return false unless in_list?\n my_position == 1\n end",
"def first?\n return false unless in_list?\n my_position == 1\n end",
"def father_of?(child)\n\t\t_c = Children.joins(:families).where(:families => {:parent_id => id, :person_id => child.id} )\n\t\tif _c.present?\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def test_previous_sibling\n setup_test_tree\n\n assert_nil(@root.previous_sibling, \"Root does not have any previous sibling\")\n assert_nil(@child1.previous_sibling, \"Child1 does not have previous sibling\")\n assert_equal(@child1, @child2.previous_sibling, \"Child2's previous sibling is Child1\")\n assert_equal(@child2, @child3.previous_sibling, \"Child3's previous sibling is Child2\")\n assert_nil(@child4.previous_sibling, \"Child4 does not have a previous sibling\")\n end",
"def dom_class_first(object, array)\n\t\tif (object == array.first)\n\t\t\treturn \"first\"\n\t\tend\n\t\tnil\n\tend",
"def first\n lock {\n first_id = resolve_steps(:first)\n first_id.nil? ? nil : _load(first_id)\n }\n end",
"def first?\n if defined? @first\n false\n else\n @first = false\n true\n end\n end",
"def min_left_child(node)\n if node.left_child.nil?\n return node\n end\n\n return min_left_child(node.left_child)\n end",
"def first?\n # return false unless in_list?\n self.send(position_column) == 1\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first(*args)\n find(:first, *args)\n end",
"def assert_first_page\n assert_no_link PREV_LABEL\n end",
"def setFirst(first)\n @first = first\n end",
"def normal\n first\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first( path_stack, node )\n return nil if path.size == 0\n\n case path[0]\n when :document\n # do nothing\n return first( path[1..-1], node )\n when :child\n for c in node.children\n r = first( path[1..-1], c )\n return r if r\n end\n when :qname\n name = path[2]\n if node.name == name\n return node if path.size == 3\n return first( path[3..-1], node )\n else\n return nil\n end\n when :descendant_or_self\n r = first( path[1..-1], node )\n return r if r\n for c in node.children\n r = first( path, c )\n return r if r\n end\n when :node\n return first( path[1..-1], node )\n when :any\n return first( path[1..-1], node )\n end\n return nil\n end",
"def test_parent\n @usergroups.each do |x|\n next if x.parentusergroupid == 0\n assert_not_nil x.parent, \"#{x.id} has no parent\"\n end\n end",
"def peek_first_item\n stack = []\n node, stack = *first_below(@root, stack)\n return nil unless node\n return node, stack\n end",
"def first\n\t\t@first.content\n\tend",
"def test_parent\n setup_test_tree\n\n assert_nil(@root.parent, \"Root's parent should be nil\")\n assert_equal(@root, @child1.parent, \"Parent should be root\")\n assert_equal(@root, @child3.parent, \"Parent should be root\")\n assert_equal(@child3, @child4.parent, \"Parent should be child3\")\n assert_equal(@root, @child4.parent.parent, \"Parent should be root\")\n end",
"def first?\n index == 0\n end",
"def first?\n index == 0\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def each_child\n childptr = CMark.node_first_child(@pointer)\n while not childptr.null? do\n nextptr = CMark.node_next(childptr)\n yield Node.new(nil, childptr)\n childptr = nextptr\n end\n end",
"def left_child\n # Returns left_child unless it's nil\n return @left_child unless @left_child.nil?\n\n # If passed the guard, left_child was not calculated yet, so generates it,\n # stores a ref and return the node\n @left_child = calculate_left_child\n @left_child\n end",
"def fourth_child\n child 3\n end",
"def on_begin(node)\n child, other_children = *node.children\n\n # Not sure if this can happen in an `if` statement\n raise LogicError if other_children\n\n case @truth.fetch(child, process(child))\n when :true\n :true\n when :false\n :false\n else\n nil\n end\n end",
"def first_children\n result = Set.new\n\n causal_link_graph = plan.event_relation_graph_for(EventStructure::CausalLink)\n relation_graph_for(Dependency).depth_first_visit(self) do |task|\n next if task == self\n\n if task != self && causal_link_graph.root?(task.start_event)\n result << task\n end\n end\n result\n end",
"def find_min_element_iterative(root)\n return nil if !root\n while root.left_child\n root = root.left_child\n end\n root\nend",
"def first\n @ordered_elements.first\n end",
"def first?\n\t locate == 1\n\tend",
"def first?\n self.index == 0\n end",
"def first_part_of_call_chain(node); end",
"def first_part_of_call_chain(node); end",
"def first\r\n self[0]\r\n end",
"def first\n @elements.empty? ? nil : @elements[0]\n end",
"def test_14a_index_of_first_item\n puts \"test_14a_index_of_first_item\"\n ll = LinkedList.new()\n ll.push(\"foo\")\n ll.push(\"bar\")\n ll.push(\"good\")\n assert_equal(0, ll.index(\"foo\"))\n end",
"def first_ele tag_name\n # XPath index starts at 1\n find_element :xpath, \"//#{tag_name}[1]\"\n end",
"def select_father_summary(person_id)\n add_parents!\n couple = parents[0] || ParentsReference.new\n couple.select_parent(person_id,'Male')\n parents[0] = couple \n end",
"def first\n goto(0)\n end",
"def first\n self[0]\n end",
"def first\n self[0]\n end",
"def first\n # return value if head node is set\n if !@head.nil?\n @head.value\n else\n # otherwise raise an exception\n raise \"List is empty\"\n end\n end",
"def first?\n index == 0\n end",
"def first!(*args, &block)\n first(nil, *args, &block)\n end",
"def third_child\n child 2\n end",
"def caar; first.first end",
"def get_first\n raise NotImplementedError, \"Please implement get_first\"\n end"
] |
[
"0.7982242",
"0.77640253",
"0.77415323",
"0.73569846",
"0.73472583",
"0.72539914",
"0.6833663",
"0.677806",
"0.67485505",
"0.67452073",
"0.6468998",
"0.64033115",
"0.6375613",
"0.6367125",
"0.62516266",
"0.61623526",
"0.61593854",
"0.60892355",
"0.60821503",
"0.60335475",
"0.6010867",
"0.6010867",
"0.5992627",
"0.59845704",
"0.5972567",
"0.59499335",
"0.5917187",
"0.59117645",
"0.59109956",
"0.5908756",
"0.58784",
"0.58622533",
"0.58379835",
"0.58248544",
"0.5818708",
"0.580221",
"0.5761911",
"0.5760889",
"0.57547724",
"0.57478166",
"0.5746741",
"0.5732712",
"0.5729237",
"0.57288957",
"0.57221365",
"0.5720131",
"0.56889325",
"0.56782484",
"0.56577605",
"0.5625119",
"0.56235814",
"0.5599876",
"0.55926156",
"0.55926156",
"0.55792445",
"0.5574471",
"0.5564277",
"0.5563678",
"0.55604035",
"0.55468357",
"0.55334526",
"0.5530264",
"0.5530264",
"0.55294555",
"0.5527229",
"0.5521048",
"0.55138135",
"0.551084",
"0.550672",
"0.5494503",
"0.5493703",
"0.5490476",
"0.5488251",
"0.5488251",
"0.54820824",
"0.5479292",
"0.5477922",
"0.54772806",
"0.54707974",
"0.5465821",
"0.5455692",
"0.54535055",
"0.5445845",
"0.54435706",
"0.54435384",
"0.54435384",
"0.5441277",
"0.5428709",
"0.54278386",
"0.5414771",
"0.5411696",
"0.5409744",
"0.54085225",
"0.54085225",
"0.5405748",
"0.540142",
"0.5399918",
"0.5399842",
"0.53994477",
"0.5398754"
] |
0.85284865
|
0
|
Test the last_child method.
|
def test_last_child
setup_test_tree
assert_equal(@child3, @root.last_child, "Root's last child is Child3")
assert_nil(@child1.last_child, "Child1 does not have any children")
assert_equal(@child4, @child3.last_child, "Child3's last child is Child4")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_sibling, \"Child2's last sibling should be child3\")\n assert_same(@child3, @child3.last_sibling, \"Child3's last sibling should be itself\")\n assert_same(@child4, @child4.last_sibling, \"Child4's last sibling should be itself\")\n assert_not_same(@child3, @child4.last_sibling, \"Child4's last sibling is itself\")\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def last *a; self.child(*a) + ':last-child' end",
"def last_child\n children.max_by { |x| x.position}\n end",
"def last\n @children.last\n end",
"def last?\n if tree.columns.counter_cache? && parent\n parent.children.size == position\n else\n !right_sibling\n end\n end",
"def last_element_child\n n = self.last_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.previous_sibling\n end\n return n\n end",
"def last_item\n @children[@items.last]\n end",
"def last() end",
"def last?\n !right_sibling\n end",
"def last?\n self.rel == \"last\"\n end",
"def last?; end",
"def remove_last_child\n @elements.pop\n end",
"def last\n end",
"def last; end",
"def last; end",
"def last; end",
"def last?\n not last.nil?\n end",
"def last?\n @last\n end",
"def last?\n @last\n end",
"def last?\n @SuccessorReference.value.is_a? Tail\n end",
"def getLastNode #not counting the sentinel node\n\tunless (@size == 0)\n\t\treturn @last.prev\n\telse\n\t\treturn nil\n\tend\nend",
"def last\n node = @tree.maximum\n node.nil? ? default : node.to_a\n end",
"def last_sibling\n node = self\n while node.next_sibling\n node = node.next_sibling\n end\n return node\n end",
"def last(*args)\n find(:last, *args)\n end",
"def last(*args)\n find(:last, *args)\n end",
"def last(*args)\n find(:last, *args)\n end",
"def find_last \n\t\tcurrent_node = @head\n\t\tuntil current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node\n\tend",
"def last?\n position == bottom\n end",
"def is_last(target)\n index = @hash[target.name].index(target)\n last = @hash[target.name].size - 1\n return index == last\n end",
"def last!\n last || raise_record_not_found_exception!\n end",
"def last(*args)\n argv = to_pointer([\"last\"] + args)\n date = rrd_last(args.size+1, argv)\n return false if date == -1\n date\n ensure\n free_pointers\n end",
"def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end",
"def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end",
"def assert_last(string, last)\n Parser.parse(string)\n Parser.last.must_equal last\n end",
"def last\n at(-1)\n end",
"def last_screen\n # print \"last_screen: \" + id.to_s + \" - \" + title + \"\\n\"\n return children.all(:order => :position).last.last_screen if has_children?\n parent_last_screen\n end",
"def last\r\n self[-1]\r\n end",
"def last\n self.each {|node| return node if node.next_node == nil}\n end",
"def last?\n\t\treturn @iteration == @items.length - 1\n\tend",
"def last\n\t\t\t@last\n\t\tend",
"def last\n self[-1]\n end",
"def last?\n # return false unless in_list?\n self.send(position_column) == bottom_position_in_list\n end",
"def last_node(node)\n return node if tail?\n last_node(node.next_node)\n end",
"def last!(group)\n return if group.class != Group\n relationship = EntityGroupRelationship.find_by(entity_id: self.id, group_id: group.id)\n return if relationship.nil?\n relationships = self.group_relations\n last = relationships.count - 1 # - 1 because child will be set to last at the end\n return if relationship.position == last\n if relationship.position.nil?\n line = 0\n else\n line = relationship.position\n end\n relationships.reverse.each do |r|\n next if r == relationship\n if r.position.nil?\n r.update_attribute(:position, last -= 1)\n else\n if r.position > line\n r.update_attribute(:position, last -= 1)\n end\n end\n end\n relationship.update_attribute( :position, relationships.count - 1 )\n end",
"def last\n self[-1]\n end",
"def last_sibling_in_list\n self.class.asc(:position).last\n end",
"def last?\n index == size - 1\n end",
"def last?\n index == size - 1\n end",
"def last\n empty? ? nil : @anchor.prev_node.value\n end",
"def last\n @tail\n end",
"def last\n relationships = self.group_relations\n last_index = relationships.count - 1\n last_relationship = relationships.select { |child| child[:position] == last_index }.first\n return if last_relationship.nil?\n last_relationship.group\n end",
"def last(*args)\n find_first_or_last(:last, *args)\n end",
"def last\n contents[contents.size - 1]\n end",
"def get_last\n return nil if @head.nil?\n return get_last_helper(@head)\n end",
"def last_parent\n @stack.reverse.find { | obj | obj.kind_of? Parent }\n end",
"def last?\n self.index == (self.array.length - 1)\n end",
"def execute_last &decision\n return execute_line @test_lines[-1], &decision\n end",
"def last_ele(class_name)\n ele_index class_name, 'last()'\n end",
"def last_ele(class_name)\n ele_index class_name, 'last()'\n end",
"def last\n list = self\n list = list.tail until list.tail.empty?\n list.head\n end",
"def last\n if @nxt\n @nxt.last\n else\n self\n end\n end",
"def last?\n index == @collection.length - 1\n end",
"def last!\n last or raise RecordNotFound\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def name_of_last_test\n unless defined? @name_of_last_test\n @name_of_last_test = nil\n tests_and_subcontexts.reverse.each do |test_or_context|\n if test_or_context.is_a? String\n @name_of_last_test = test_or_context\n break\n end\n unless test_or_context.name_of_last_test.nil?\n @name_of_last_test = test_or_context.name_of_last_test\n break\n end\n end\n end\n @name_of_last_test\n end",
"def last_item?\n self.simple_acts_as_list_scope.last == self\n end",
"def get_last\n raise NotImplementedError, \"Please implement get_last\"\n end",
"def last\n\t\t@last.content\n\tend",
"def last\n @tail.val\n end",
"def get_last\n return @tail ? @tail.data : nil\n end",
"def last_ele tag_name\n xpath \"//#{tag_name}[last()]\"\n end",
"def get_last\r\n return unless @head\r\n \r\n last = @head\r\n last = last.next until last.next.nil?\r\n last.data\r\n end",
"def last\n node = @head;\n return node if node.next.nil?\n until (node.next.nil?) #until end of list\n node = node.next\n return node if node.next.nil?\n end\n end",
"def get_last\n return nil if @head.nil?\n return last_node.data\n end",
"def last\n all[all.size - 1]\n end",
"def test_last_three\n array = [1,2,3,4,5]\n array = array.last(3)\n assert_equal [3,4,5], array\n end",
"def assert_last_page\n assert_no_link NEXT_LABEL\n end",
"def last\n \tbegin\n \t raise ArgumentError, \"Empty LinkedList\" if @size <= 0\n \t return @last.prev.data\n \t rescue\n \t puts \"Empty\" \t\t \n\t\t end\n \tend",
"def last\n\t\t@tail.info if !@tail.nil?\n\tend",
"def test_find_last_test_id\n create_template(\"Test Template\")\n template_id = find_last_template_id\n create_test(template_id)\n last_test_id = @db.find_last_test_id\n\n assert_equal(last_test_id[:id], find_last_test_id)\n\n delete_template(template_id)\n end",
"def last(*args)\n all.send(:last, *args)\n end",
"def last\n tail.data\n end",
"def last\n all.last\n end",
"def find_last &predicate\n return nil unless block_given? \n current = self.tail\n while current\n return current if predicate.call(current)\n current = current.prev\n end\nend",
"def end\n empty? ? 0 : last.end\n end",
"def bottom_item(except = nil)\n except ? siblings.reject{|page| page == self }.last : siblings.last\n end",
"def delete_last()\n \n end",
"def get_last\n node = head\n until node.next.nil?\n node = node.next\n end\n return node.data\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last(repo)\n find(repo)\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def last\n goto(last_page_index())\n end",
"def get_last\n return @position\n end",
"def peek_last\n raise 'No such element' if @size == 0\n @tail.value\n end",
"def last\n @ordered_elements.last\n end"
] |
[
"0.8076884",
"0.77156967",
"0.7451575",
"0.7406189",
"0.73204654",
"0.69250536",
"0.67753804",
"0.6684065",
"0.66303384",
"0.6609797",
"0.6565042",
"0.6476528",
"0.6403612",
"0.639643",
"0.6366839",
"0.6366839",
"0.6366839",
"0.63501596",
"0.632775",
"0.632775",
"0.6220421",
"0.6195818",
"0.6194739",
"0.61701316",
"0.6162142",
"0.6151561",
"0.6151561",
"0.6141568",
"0.61261594",
"0.61251336",
"0.6123658",
"0.61231333",
"0.61144644",
"0.61144644",
"0.6113251",
"0.6112642",
"0.61047673",
"0.60895216",
"0.60756445",
"0.60596293",
"0.6053232",
"0.6028576",
"0.60275334",
"0.60267043",
"0.60236573",
"0.60197717",
"0.60102165",
"0.59859914",
"0.59859914",
"0.5965099",
"0.59484756",
"0.59281045",
"0.5883036",
"0.5880695",
"0.587525",
"0.58677",
"0.58484197",
"0.5812724",
"0.5810926",
"0.5810926",
"0.57931703",
"0.57904345",
"0.5784425",
"0.57767",
"0.5767454",
"0.5767454",
"0.5759899",
"0.5730202",
"0.5728385",
"0.5721888",
"0.5721682",
"0.57213736",
"0.5720537",
"0.57128656",
"0.57043684",
"0.5699606",
"0.56899565",
"0.5687556",
"0.5680018",
"0.56746423",
"0.56722295",
"0.564901",
"0.56259954",
"0.5613007",
"0.56048566",
"0.5603481",
"0.5593529",
"0.5586268",
"0.5585309",
"0.5581856",
"0.5578654",
"0.5578654",
"0.5578654",
"0.5578654",
"0.5566987",
"0.55655605",
"0.5562702",
"0.5555716",
"0.5552078",
"0.5551565"
] |
0.8650782
|
0
|
Test the find method.
|
def test_find
setup_test_tree
found_node = @root.find { |node| node == @child2}
assert_same(@child2, found_node, "The node should be Child 2")
found_node = @root.find { |node| node == @child4}
assert_same(@child4, found_node, "The node should be Child 4")
found_node = @root.find { |node| node.name == "Child4" }
assert_same(@child4, found_node, "The node should be Child 4")
found_node = @root.find { |node| node.name == "NOT PRESENT" }
assert_nil(found_node, "The node should not be found")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find; end",
"def find\n fail NotImplementedError\n end",
"def find\n raise \"Method not implemented\"\n end",
"def find(value)\n end",
"def find_by()\n\n end",
"def test_find\n assert_not_nil @rdigg.user.find(\"kevinrose\")\n end",
"def test_0150_find\n @@log.debug \"test_0150_find starts\" if @@log.debug?\n assert_respond_to(@list, :find, \"test_0150_find_respond\")\n # Object with .last == \"Dev\"\n persobj = @list.find {|obj| obj.last == \"Dev\" }\n assert_equal(@dad, persobj, \"test_0150_find_feq_01\")\n # Object with .last == \"Allard\"\n sorry = lambda { \"not found\" }\n persobj = @list.find(sorry) {|obj| obj.last == \"Allard\" } \n assert_equal(\"not found\", persobj, \"test_0150_find_feq_02\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.find\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0150_find_enumcheck\")\nelse\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0150_find_enumenumcheck\")\nend\n @@log.debug \"test_0150_find ends\" if @@log.debug?\n end",
"def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end",
"def find(name); end",
"def find(input)\n end",
"def find item\n\tend",
"def test_find_player_found\n new_team = Team.new(\"Kerbals\", [\"Jeb\", \"Bob\", \"Bill\", \"Val\"], \"Gene\")\n search = new_team.find_player(\"Bob\")\n assert_equal(true, search)\n end",
"def find(id)\n find_result\n end",
"def find!\n @total_found = 0\n @results = nil\n return results\n end",
"def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end",
"def find(query); end",
"def find(query); end",
"def test_galleryphoto_find\n assert_not_nil @rdigg.galleryphoto.find(\"7987168\")\n end",
"def find\n\t\tif !defined?(@collection)\n\t\t\treturn false\n\t\telse\n\t\t\treturn @collection.find\n\t\tend\n end",
"def find(id); end",
"def find(id); end",
"def find(args, mode); end",
"def find(id)\n raise NotImplementedError\n end",
"def test_find_by_title\n assert_equal(@todo1, @list.find_by_title(\"Buy milk\"))\n end",
"def found\n return @found\n end",
"def search(find_val)\n false\n end",
"def find(id)\n finder_or_run(:find, id)\n end",
"def simple_find(*args, &blk)\n find(:__no_pretty_finder__, nil, *args, &blk)\n end",
"def find(id)\n\nend",
"def test_find_with_string\n assert_equal(Topic.find(1).title, Topic.find(\"1\").title)\n end",
"def test_that_find_by_url_finds_us_when_nothing_else_matches\n assert_equal @page, @root.find_by_url(\"a/page\")\n end",
"def find\n\t\tif defined?(@collection)\n\t\t\treturn @collection.find\n \tend\n\tend",
"def find(*args, **options, &optional_filter_block)\n LOG.info(\"Capybara find #{args.join(' ')}\")\n super\n end",
"def find_all\n fail NotImplementedError\n end",
"def find(*args)\n records = super\n @after.call(records) if @after\n records\n end",
"def find(path); end",
"def find(path); end",
"def test_user_find_friend\n assert_not_nil @rdigg.user.find(\"kevinrose\", \"obamaforamerica\")\n end",
"def my_array_finding_method(source, thing_to_find)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def find(sess, what, *args) #:nodoc:\r\n get(sess, *args)\r\n end",
"def test_cant_find_single_item\n\n result=find_single_item(@warehouse_data, :zz)\n assert_equal(nil,result)\n \nend",
"def test_find_movie_title_already_exists\n movies = Movies.new(@movies)\n result = movies.find_movie('Titanic')\n assert_equal(true, result)\n end",
"def find(_index_value)\n raise \"Implement in subclass\"\n end",
"def find(loc, data)\n list.find(loc, data)\n end",
"def find(options = {})\n tmp = nil\n @member_class.with_scope(options) do\n tmp = @owner.send(@find_proc, @find_options)\n end\n return tmp\n end",
"def test_galleryphotos_find\n assert_not_nil @rdigg.galleryphotos.find(:count => 3)\n end",
"def after_find\n end",
"def find_by_name(name)\n end",
"def find(*args)\n find_all(*args).first\n end",
"def test_0190_find_all\n @@log.debug \"test_0190_find_all starts\" if @@log.debug?\n assert_respond_to(@list, :find_all, \"test_0190_find_all_respond\")\n # Basic find_all check\n ta = @list.find_all {|obj| obj.first <= \"Bob\" }\n assert_equal([@aen, @bsb], ta, \"test_0190_find_all_eq01\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.find_all\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0190_find_all_enumcheck\")\nelse\n # Note: the author's version of the 1.8 Pickaxe documents this\n # as an Array. Note however that this form is not documented by\n # that publication at all.\n # YMMV.\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0190_find_all_enumenumcheck\")\nend\n @@log.debug \"test_0190_find_all ends\" if @@log.debug?\n end",
"def test_find_order\n assert_nothing_raised {\n Order.find(@order.id)\n }\n end",
"def find list, &block\n list.find &block\nend",
"def find_with_rpc_failed\n rpc_failed('Find failed')\n end",
"def find(*args)\n return super if block_given?\n find_with_ids(*args)\n end",
"def test_find_count\n assert_equal(6, @coll.find().limit(2).count())\n end",
"def find list, &block\n list.find(&block)\nend",
"def find\n debugger\n self.lost = false\n debugger\n end",
"def test_find_test\n create_template(\"Test Template\")\n template_id = find_last_template_id\n create_test(template_id)\n\n test = @db.find_test(find_last_test_id)\n assert_instance_of(Hash, test)\n\n delete_template(template_id)\n end",
"def test_0670_find_index\n @@log.debug \"test_0670_find_index starts\" if @@log.debug?\n assert_respond_to(@list, :find_index, \"test_0670_find_index_respond\")\n # Type check\n enum = @list.find_index\n result = enum.is_a? Enumerator\n assert(result,\"test_0670_find_index_class\") \n # nil check\n enum = @list.find_index {|item| false }\n assert_nil(enum, \"test_0670_find_index_allfalse\")\n # Index check\n found = @list.find_index {|item| item.ndata == 3 }\n assert(found == 1, \"test_0670_find_index_ndata3\")\n #\n @@log.debug \"test_0670_find_index ends\" if @@log.debug?\n end",
"def test_find_random_should_return_different_collections\n assert User.find(:random, :limit => 10) != User.find(:random, :limit => 10)\n end",
"def find(method, args = {})\n # make calls to the right method based on the method and the arguments\n self.client.call(operations[method], args)\n end",
"def student_find(name)\n\t@directory_students.find {|student|students_equal(student,name)}\n\tend",
"def assert_find_all(cls, check_method, repo, user)\n repo_method = cls.resource_name(:plural)\n \n item1 = cls.find_all(user.login, repo.name).first\n item2 = cls.find_all(repo).first\n item3 = repo.send(repo_method).first\n \n assert_equal item1.send(check_method), item2.send(check_method)\n assert_equal item1.send(check_method), item3.send(check_method)\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(&block)\n return nil unless valid?\n @hops.find(&block)\n end",
"def test_find_by_integer_not_found\n # Person.find(1) - returns the object for ID = 1\n assert !IndestructiblePost.exists?(9999)\n assert_raises(ActiveRecord::RecordNotFound) {\n IndestructiblePost.find(9999)\n }\n end",
"def find(*args)\n ids = args.__find_args__\n raise_invalid if ids.any?(&:nil?)\n for_ids(ids).execute_or_raise(ids, args.multi_arged?)\n end",
"def find(path, type, setting); end",
"def test_user_find_dugg\n assert_not_nil @rdigg.user.find_dugg(\"kevinrose\")\n end",
"def test_media_find_all\n assert_not_nil @rdigg.media.find_all\n end",
"def find_all\n end",
"def method_for_find\n :find_by_slug!\n end",
"def test_find_account\n an_account_id = order_accounts(:santa_account).id\n assert_nothing_raised {\n OrderAccount.find(an_account_id)\n }\n end",
"def test_find_single_item\n\n result=find_single_item(@warehouse_data, :b7)\n assert_equal(\"bath fizzers\",result)\n \nend",
"def test_find_player_in_players()\n team = SportsTeam.new(\"Belgium\", [\"Player 1\", \"Player 2\", \"Player 3\"], \"Mr Belgium\")\n assert_equal(\"Player 2\", team.find_player_in_players(\"Player 2\"))\n end",
"def find_all\n finder_or_run(:find_all)\n end",
"def test_find_book__missing\n\n single_book = @library1.find_book(\"tek_wars\")\n\n assert_nil(single_book)\n\n end",
"def find_in_collection(_id)\n raise(NotImplementedError, '#find_in_collection must be defined in the TypicalSituation implementation.')\n end",
"def test_find_fake_rubies_zero\r\n\t\tassert_equal 0, @t2.find_fake_rubies\r\n\tend",
"def test_should_find_product\n a_product_id = items(:chinchilla_coat).id\n assert_nothing_raised {\n Product.find(a_product_id)\n }\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def define_find_method(name, builder)\n define_helper \"find_#{name}\", ->(id) { builder.find(id) }\n end",
"def test_user_find_fans\n assert_not_nil @rdigg.user.find_fans(\"kevinrose\")\n end",
"def find(*args)\n select(*args)\n\n=begin\n\n options = args.last.is_a?(Hash) ? args.pop : {}\n case args.first\n when :all then find_every options\n when :first then find_initial options\n else find_from_ids args, options\n end\n\n=end\n\n end",
"def find(id)\n end",
"def test_galleryphoto_find_comment\n assert_not_nil @rdigg.galleryphoto.find_comment(\"7987168\", \"5\")\n end",
"def test_find\n @search.adjacent_points_function = ->(current) {[-0.1, 0.1].map {|x| current + x}}\n @search.cost_function = ->(x){x - 0.1}\n assert_in_delta 0.1, @search.find\n end",
"def find(root, params)\n FileSearcher.call(root, params)\nend",
"def find\n each { |x| return x if yield x }\n end",
"def find(input, property, value); end",
"def find_object(name); end",
"def test_search\n mock_town = Minitest::Mock.new('Town')\n def mock_town.mine; [0, 0]; end\n\n def mock_town.return_name; 'Name'; end\n\n p1 = Prospector::new mock_town\n test_i = p1.search\n assert_equal test_i, -1\n end",
"def find(key)\n helper_find(@root, key)\n end",
"def test_media_find_by_type\n assert_not_nil @rdigg.media.find_by_type(\"news\")\n end",
"def find(conditions)\n @root.find(conditions)\n end"
] |
[
"0.78023165",
"0.77532566",
"0.746425",
"0.69116193",
"0.69103605",
"0.68870854",
"0.67851675",
"0.67456454",
"0.67143756",
"0.6703975",
"0.6683145",
"0.66625124",
"0.6575091",
"0.6570424",
"0.65411603",
"0.65147233",
"0.65147233",
"0.64343196",
"0.6433345",
"0.63966596",
"0.63966596",
"0.63866425",
"0.6380784",
"0.6353489",
"0.63407034",
"0.6331306",
"0.63289493",
"0.6316682",
"0.63096267",
"0.63082856",
"0.6305204",
"0.62695175",
"0.6266961",
"0.62453943",
"0.6239129",
"0.6195352",
"0.6195352",
"0.6184677",
"0.6154971",
"0.61495054",
"0.61263865",
"0.6117985",
"0.61074156",
"0.60972196",
"0.60941",
"0.6083194",
"0.6078684",
"0.6065635",
"0.60551494",
"0.60352844",
"0.60329676",
"0.6015492",
"0.59774494",
"0.5960027",
"0.5958022",
"0.5952235",
"0.5944066",
"0.59302384",
"0.5913862",
"0.59108996",
"0.590805",
"0.5907267",
"0.5902693",
"0.5892658",
"0.5892658",
"0.5888767",
"0.58859265",
"0.58838373",
"0.5873692",
"0.5854553",
"0.5845887",
"0.58429486",
"0.5840417",
"0.58390605",
"0.58273447",
"0.5822684",
"0.5816565",
"0.5816496",
"0.5813909",
"0.580743",
"0.57979465",
"0.57913864",
"0.57913864",
"0.57913864",
"0.57913864",
"0.57913864",
"0.5783545",
"0.5771319",
"0.5768207",
"0.57666653",
"0.5752837",
"0.57527953",
"0.5751354",
"0.5751044",
"0.5748914",
"0.5748636",
"0.57460546",
"0.574483",
"0.57393014",
"0.5737368"
] |
0.69797987
|
3
|
Test the parentage method.
|
def test_parentage
setup_test_tree
assert_nil(@root.parentage, "Root does not have any parentage")
assert_equal([@root], @child1.parentage, "Child1 has Root as its parent")
assert_equal([@child3, @root], @child4.parentage, "Child4 has Child3 and Root as ancestors")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def display_parent_child_test_cases\n \n end",
"def child_condition; end",
"def parent\n self.sample || self.test_subject\n end",
"def override()\n puts \"CHILD override()\"\n end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def should; super end",
"def _parent; end",
"def test_age_of_person()\n\n end",
"def parent_variable; end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\" # change to altered() before calling the base class instance method with same name\n super() # base method with name name is call here\n puts \"CHILD, AFTER PARENT altered()\" # change to altered() after calling the base class instance method with same name\n end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\" \n super() # calls the super function so the program will use the function defined in the parent class\n puts \"CHILD, AFTER PARENT altered()\"\n end",
"def override() # Note that despite the module.override, this still overrides\r\n puts \"CHILD override()\"\r\n end",
"def parent\n end",
"def parent\n end",
"def parent\n end",
"def parent\n end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\"\n super()\n puts \"CHILD, AFTER PARENT altered()\"\n end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def semplice\r\n puts \"senza parentesi\"\r\nend",
"def test_modified\n parent = RoBaseIf.new( 'parent', '' )\n base = RoBaseIf.new( 'lab1', '' )\n base.parent = parent\n assert_equal false, parent.modified\n assert_equal false, base.modified\n base.value = 'A'\n assert_equal true, parent.modified\n assert_equal true, base.modified\n end",
"def ar_verify_parent_resource\r\n parent= ardata.parent_resources.select { |res| res.model == @parent_resource.class }\r\n \r\n real_parent= @resource.send(parent.first.singular)\r\n \r\n if @parent_resource.to_param != real_parent.to_param\r\n @parent_resource= real_parent\r\n ar_set_parent_instance_var if @parent_resource\r\n end\r\n end",
"def parent?\n true \n end",
"def super_method \n \n puts \"Method of superclass\"\n end",
"def test_parent\n setup_test_tree\n\n assert_nil(@root.parent, \"Root's parent should be nil\")\n assert_equal(@root, @child1.parent, \"Parent should be root\")\n assert_equal(@root, @child3.parent, \"Parent should be root\")\n assert_equal(@child3, @child4.parent, \"Parent should be child3\")\n assert_equal(@root, @child4.parent.parent, \"Parent should be root\")\n end",
"def altered()\n puts \"PARENTS altered()\"\n end",
"def test_edit(pid)\n result = super\n if result\n return result\n else\n return test_edit_from_policy(pid)\n end\n end",
"def super_method \n puts \"Method of a superclass\"\n end",
"def child_of?(parent); end",
"def calls_super # :nodoc:\n false\n end",
"def expect_before_nested_method_call; end",
"def initialize(parent); end",
"def test_under_age\n\t\tassert_equal true, @user.age(14)\n\tend",
"def self_test; end",
"def self_test; end",
"def children\n child_check\n super\n end",
"def parent_command; end",
"def child?\n true\n end",
"def test_over_age\n\t\tassert_equal true, @user.age(19)\n\tend",
"def parentage\n get_parents unless @already_fetched_parents\n @already_fetched_parents = true\n super\n end",
"def be_a_child_of(parent)\n simple_matcher(\"controller to be a child of '#{parent}'\") do |controller_class|\n controller.class.options[:parent] == parent\n end\n end",
"def super_method; end",
"def process_hook\n fail 'child class to implement'\n end",
"def original?\n self.parent == self\n end",
"def test_check_before_destroy(parent, child)\n # Ensure that can destroy parent without child\n @parent = Factory(parent)\n lambda do\n @parent.destroy\n end.should change(parent.to_s.camelcase.constantize, :count).by(-1)\n \n @parent = Factory(parent)\n # Stub so that it appears @parent does have child records.\n @parent.stub(child.to_s.pluralize).and_return([1])\n @parent.stub(child).and_return([1])\n lambda do\n @parent.destroy\n end.should_not change(parent.to_s.camelcase.constantize, :count)\n end",
"def test_read(pid)\n result = super\n if result\n return result\n else\n return test_read_from_policy(pid)\n end\n end",
"def parent( &block )\n return unless parent?\n raise ArgumentError, \"A block must be supplied\" if block.nil?\n\n if block.arity > 0\n block.call(self)\n else\n block.call\n end\n end",
"def parent_correct?(id,parent)\n p __method__ if @debug == true\n\n # get the suggested pathname .. using the pathname library here.\n path = Pathname.new(id).dirname\n\n # get the parent ci from the rest interface\n xml = RestClient.get \"#{@base_url}/ci/#{path}\", {:accept => :xml, :content_type => :xml}\n\n # get the parent type from the xml\n parenttype = XmlSimple.xml_in(xml,{'KeepRoot' => true}).keys.to_s\n # check if the actual parenttype is among the valid ones\n return true if parent.include? parenttype\n\n return false\n end",
"def inherited(base); end",
"def parent\n page\n end",
"def eat(food, two)\n binding.pry # self\n super(\"fish\") # call the eat method in the parent class\n puts \"Play with #{food}.\"\n\n end",
"def superclass() end",
"def parent\n return investigation\n end",
"def check_new_parent_class\n if is_protonym? && parent_id != parent_id_was && !parent_id_was.nil? && nomenclatural_code == :iczn\n if old_parent = TaxonName.find_by(id: parent_id_was)\n if (rank_name == 'subgenus' || rank_name == 'subspecies') && old_parent.name == name\n errors.add(:parent_id, \"The nominotypical #{rank_name} #{name} can not be moved out of the nominal #{old_parent.rank_name}\")\n end\n end\n end\n end",
"def parents; end",
"def child?\n false\n end",
"def method_missing(name, *args, &block)\n block ||= lambda {} # captures self HERE\n if @parent\n @parent.send(name, *args, &block)\n else\n super\n end\n end",
"def method_missing(name, *args, &block)\n block ||= lambda {} # captures self HERE\n if @parent\n @parent.send(name, *args, &block)\n else\n super\n end\n end",
"def derived_implementor?(parent, method_name)\n\t\t(self.method(method_name).to_s.match(/#{parent}[^:]/)) ? false : true\n\tend",
"def parent?\n true\n end",
"def parent?\n false\n end",
"def testing\n # ...\n end",
"def estimated_child_age(age)\n\tage / 2\nend",
"def super_before(&b)\n @expectation.super_before(&b)\n self\n end",
"def default_test\n info \"self: #{self}\"\n end",
"def test_parent\n PictureTag.stubs(:html_attributes).returns('parent' => 'class=\"parent\"')\n\n correct = <<~HEREDOC\n <img src=\"good_url\" srcset=\"ss\" class=\"parent\">\n HEREDOC\n\n assert_equal correct, @tested.to_s\n end",
"def added_parent_object(parent, relations, info)\n super if defined? super\n return if !relations.include?(ExecutionAgent)\n return if used_as_execution_agent?\n\n ready_event.when_unreachable(true, &ExecutionAgentGraphClass.method(:execution_agent_failed_to_start))\n on :stop, &ExecutionAgentGraphClass.method(:pending_execution_agent_failed)\n\n self.used_as_execution_agent = true\n end",
"def evaluate( test )\n raise NoMethodError, \"You must override this method.\"\n end",
"def initialize(parent)\n @parent = parent\n end",
"def method_missing(name, *args, &block)\n if parent && parent.respond_to?(name)\n block ||= lambda {} # captures self HERE\n parent.send(name, *args, &block)\n else\n super\n end\n end",
"def parent_api; end",
"def parent_api; end",
"def before_test(test); end",
"def before_test(test); end",
"def has_parent!(parent)\n @parent = parent\n self\n end",
"def test_method\n end",
"def parent\n send(parent_type)\n end",
"def parent_frame; end",
"def parent=(other); end",
"def test_fish_in_river()\n assert_equal(0, @river.fish_in_river())\n end",
"def ptest_method_1(test); end",
"def validate_up\n index_in_parent_assert\n parent.validate_up\n ui.puts \"#{indent}ok child is in parent (#{short} in #{parent.short})\"\n end",
"def initialize(first_name, last_name, year_of_birth)\n#'super' is method caller\n super(first_name, last_name, year_of_birth) # => run same method in parent class\n @knowledge_level = rand(10) # => gives random #s\n end",
"def parentable?\n false\n end",
"def parent=(obj); end",
"def before() ; end"
] |
[
"0.658933",
"0.65447915",
"0.6414217",
"0.6406607",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.63398546",
"0.6254013",
"0.62044454",
"0.61957926",
"0.61906064",
"0.6155193",
"0.6129935",
"0.6083938",
"0.6069549",
"0.6069549",
"0.6069549",
"0.6069549",
"0.5993602",
"0.5991416",
"0.5991416",
"0.5991416",
"0.5991416",
"0.5991416",
"0.5948295",
"0.5932849",
"0.588147",
"0.58701813",
"0.581689",
"0.5785303",
"0.5781119",
"0.5742049",
"0.57413954",
"0.57405484",
"0.5725264",
"0.57019",
"0.5642766",
"0.5640673",
"0.5639562",
"0.5639562",
"0.5633897",
"0.5624925",
"0.5622547",
"0.5609052",
"0.56016403",
"0.5591809",
"0.55834854",
"0.55591637",
"0.55354106",
"0.553424",
"0.55061847",
"0.5503074",
"0.54886717",
"0.54853773",
"0.5480969",
"0.5474579",
"0.54668033",
"0.54661846",
"0.54554707",
"0.5450578",
"0.54411554",
"0.5434259",
"0.5434259",
"0.54295933",
"0.5428675",
"0.5427224",
"0.5418687",
"0.5412351",
"0.5411725",
"0.54018956",
"0.53942865",
"0.5393435",
"0.53888327",
"0.5375958",
"0.5374729",
"0.53733456",
"0.53733456",
"0.5371615",
"0.5371615",
"0.53684944",
"0.5364073",
"0.5355166",
"0.5354939",
"0.53545904",
"0.5352689",
"0.535081",
"0.53448623",
"0.5340354",
"0.53372735",
"0.53328836",
"0.5330031"
] |
0.6502638
|
2
|
Test the each method.
|
def test_each
setup_test_tree
assert(@root.has_children?, "Should have children")
assert_equal(5, @root.size, "Should have five nodes")
assert(@child3.has_children?, "Should have children")
nodes = []
@root.each { |node| nodes << node }
assert_equal(5, nodes.length, "Should have FIVE NODES")
assert(nodes.include?(@root), "Should have root")
assert(nodes.include?(@child1), "Should have child 1")
assert(nodes.include?(@child2), "Should have child 2")
assert(nodes.include?(@child3), "Should have child 3")
assert(nodes.include?(@child4), "Should have child 4")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each(*) end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each(&block)\n tests.each(&block)\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n raise 'Not implemented'\n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block)\n end",
"def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end",
"def each(&block)\n\n end",
"def each(&a_proc); end",
"def each(&block)\nend",
"def each &block\n end",
"def each(&block)\n raise NotImplementedError\n end",
"def each(&block)\n raise NotImplementedError\n end",
"def test_0920_each_entry\n @@log.debug \"test_0920_each_entry starts\" if @@log.debug?\n assert_respond_to(@list, :each_entry, \"test_0920_each_entry_respond\")\n # Type check\n enum = @list.each_entry\n type_check = enum.is_a? Enumerator\n assert(type_check,\"test_0920_each_entry_class\")\n # :TODO: Realistic example(s).\n @@log.debug \"test_0920_each_entry ends\" if @@log.debug?\n end",
"def each\n yield self\n end",
"def each(options={}, &block)\n end",
"def iterate(expected, meth=:each, *args)\n\t\tlambda { |obj|\n\t\t\tt = []\n\t\t\tobj.__send__(meth, *args) { |v| t << v }\n\t\t\tt == expected\n\t\t}\n\tend",
"def each(&block)\n all.each(&block)\n end",
"def each(&block)\n @all.each(&block)\n end",
"def each\n for each element\n yield(element)\n end\nend",
"def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end",
"def each(&blk); each_value(&blk) ; end",
"def _each(&block)\n _next.each(&block) if _next\n end",
"def each(&block)\n @collection.each(&block)\n end",
"def each(&block)\n specs.each(&block)\n end",
"def each(node, &block); end",
"def each\n @items.each {|x| yield x}\n end",
"def each(&block)\n @collection.each(&block)\n end",
"def each\n all.each do |el|\n yield el\n end\n end",
"def each # And define each on top of next\n loop {yield self.next }\n end",
"def each\n return enum_for(:each) unless block_given?\n\n @data.collection.each { |item| yield item }\n end",
"def each\n\t\t\t@elements.each\n\t\tend",
"def each(&block) # block into proc\n\nend",
"def my_each(&prc)\n end",
"def each\n all.each do |el|\n yield el\n end\n end",
"def each\n # Include every to be inside enumerable:\n yield \"pizza\"\n yield \"spaghetti\"\n yield \"salad\"\n yield \"water\"\n yield \"bread\"\n end",
"def each\n return enum_for(:each) unless block_given?\n @list.each do |item|\n yield item\n end\n end",
"def each(&block)\n @items.each(&block)\n end",
"def each\n items.each { |itm| yield itm }\n end",
"def test_try_each_instead_of_collect_change_array\n array = [1, 2, 3]\n array = array.each { |item| item + 10 }\n #assert_equal [11, 12, 13], array\n assert_equal [1, 2, 3], array\n end",
"def each\n yield \"pizza\"\n yield \"spaghetti\"\n yield \"salad\"\n yield \"bread\"\n yield \"water\"\n end",
"def each\r\n @many = true\r\n yield(self)\r\n end",
"def each_set\n \n end",
"def each # And define each on top of next\n loop { yield self.next }\n end",
"def each(&block)\n call_client(:each, &block)\n end",
"def each(&block)\n items.each &block\n end",
"def each(&block)\n items.each &block\n end",
"def each\n yield \"pizza\"\n yield \"spagetti\"\n yield \"salad\"\n yield \"bread\"\n yield \"water\"\n end",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def iterate\n raise \"You should implement this\"\n end",
"def test_foreach\n\t\tOle::Storage.open(@io) {\n\t\t\t|zf|\n\n\t\t\tblockCalled = false\n\t\t\tassert_raise(Errno::ENOENT, \"No such file or directory - noSuchDir\") {\n\t\t\t\tzf.dir.foreach(\"noSuchDir\") { |e| blockCalled = true }\n\t\t\t}\n\t\t\tassert(! blockCalled)\n\n\t\t\tassert_raise(Errno::ENOTDIR, \"Not a directory - file1\") {\n\t\t\t\tzf.dir.foreach(\"file1\") { |e| blockCalled = true }\n\t\t\t}\n\t\t\tassert(! blockCalled)\n\n\t\t\tentries = []\n\t\t\tzf.dir.foreach(\".\") { |e| entries << e }\n\t\t\tassert_equal(['.', '..', \"dir1\", \"dir2\", \"file1\"].sort, entries.sort)\n\n\t\t\tentries = []\n\t\t\tzf.dir.foreach(\"dir1\") { |e| entries << e }\n\t\t\tassert_equal(['.', '..', \"dir11\", \"file11\", \"file12\"], entries.sort)\n\t\t}\n\tend",
"def each(&block)\n internal_collection.each(&block)\n end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def each(&block)\n find_each(&block)\n end",
"def each(&block)\n @items.each(&block)\n self\n end",
"def each_identity; end",
"def each( &block ) # :yields: item\n @truth.each {|e| yield e }\n feedme.each {|e| yield e } while !@done\n end",
"def test_methods_can_call_yield_many_times\n result = []\n many_yields { |item| result << item }\n assert_equal [:peanut, :butter, :and, :jelly], result\n end",
"def my_all?\n status = true\n self.my_each do |item|\n if (yield item) != true\n status = false\n end\n end\n status\n end",
"def each(*args,&blk)\n\t\t@rounds.each(*args,&blk) \n\tend",
"def each(&block)\n\n all.each { |wi| block.call(wi) }\n end",
"def each\n @collection.each { |c| yield c }\n end",
"def each\n @base.each { |item| (yield item) if @filter.call(item) }\n end",
"def each(&block)\n results.each(&block)\n end",
"def each(&block)\n return all.each(&block)\n end",
"def each(&block)\n\t\t\t self.get.each &block\n\t\t\tend",
"def each &block\n return enum_for :each unless block_given?\n\n each_page do |page|\n page.each(&block)\n end\n end",
"def each(&block)\n each_element(block) if @xml\n end",
"def each\n @items.each { |_item| yield _item }\n end",
"def each(&block)\n @results.each(&block)\n end",
"def each(node, &block)\n visit(node, &block)\n end",
"def each\n\n\t\t@a.each do |x|\n\t\t\tyield x\n\t\tend\n\tend",
"def each\n @items.each { |i| yield i }\n end"
] |
[
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.7758466",
"0.77246624",
"0.7612229",
"0.7612229",
"0.7612229",
"0.7612229",
"0.7612229",
"0.7612229",
"0.75326544",
"0.7521627",
"0.7521627",
"0.7488237",
"0.7487856",
"0.7486103",
"0.7486103",
"0.7486103",
"0.7486103",
"0.7486103",
"0.7486103",
"0.7455186",
"0.74162704",
"0.73470163",
"0.72748923",
"0.7160888",
"0.715334",
"0.7135122",
"0.7049925",
"0.69899476",
"0.69703346",
"0.6951987",
"0.69218904",
"0.6911951",
"0.6896916",
"0.6883975",
"0.68725383",
"0.6858774",
"0.6844866",
"0.68417287",
"0.6821746",
"0.6816943",
"0.67958486",
"0.6790155",
"0.6789448",
"0.6756138",
"0.67370313",
"0.6732871",
"0.6722608",
"0.6678151",
"0.66467184",
"0.6645722",
"0.6641282",
"0.6636332",
"0.6624043",
"0.65884554",
"0.6573099",
"0.6568377",
"0.65648484",
"0.65586895",
"0.6557744",
"0.6547233",
"0.6547233",
"0.6542285",
"0.6539953",
"0.6539953",
"0.6539893",
"0.65360796",
"0.6535397",
"0.65229523",
"0.65229523",
"0.65229523",
"0.6517914",
"0.6503677",
"0.64995193",
"0.64944446",
"0.6477466",
"0.64754647",
"0.6473753",
"0.64676213",
"0.6454021",
"0.6435816",
"0.64355886",
"0.6431436",
"0.642342",
"0.6419577",
"0.64071",
"0.63901544",
"0.6377497",
"0.6375638",
"0.6375053",
"0.63685226"
] |
0.6459353
|
88
|
Test the each_leaf method.
|
def test_each_leaf
setup_test_tree
nodes = []
@root.each_leaf { |node| nodes << node }
assert_equal(3, nodes.length, "Should have THREE LEAF NODES")
assert(!nodes.include?(@root), "Should not have root")
assert(nodes.include?(@child1), "Should have child 1")
assert(nodes.include?(@child2), "Should have child 2")
assert(!nodes.include?(@child3), "Should not have child 3")
assert(nodes.include?(@child4), "Should have child 4")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end",
"def each_leaf(&block)\n each_leaf_node([], @root, block)\n end",
"def each_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf\n end\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def iterate(itr)\n itr.call(@leaf)\n end",
"def is_leaf\n true\n end",
"def is_leaf\n true\n end",
"def leaf?; @leaf; end",
"def each_visible_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf if leaf.visible\n end\n end",
"def each(&proc)\n @subtrees.each(&proc)\n end",
"def leaf?\n true\n end",
"def leaf?; false end",
"def each_child\n \n end",
"def assert_leaf(node)\n assert node.element_children.empty?, 'expected no children', node\n end",
"def each(&block)\n tree.each(&block)\n end",
"def is_leaf\n return @left == nil\n end",
"def _leaf(name, rx, ignorable: false, boundary: false, tests: [], preconditions: [], process: nil)\n raise Error, 'tests must be an array' unless tests.is_a? Array\n raise Error, 'preconditions must be an array' unless preconditions.is_a? Array\n\n init\n init_check(name)\n name = name.to_sym\n return if dup_check(:leaf, name, rx, tests + preconditions)\n\n tests << [process] if process\n @leaves << Leaf.new(name, rx, ignorable: ignorable, boundary: boundary, tests: tests, preconditions: preconditions)\n end",
"def each(&blk)\n @trees.each_value(&blk)\n end",
"def leaf?\n !node?\n end",
"def each &block\n return enum_for(:each) unless block_given?\n return if !@root\n @root.each &block\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def each(&block)\n root.each(&block)\n end",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def leaf_node?(node_id)\n @leaf_count < node_id\n end",
"def each &block\n @root.each(&block)\n end",
"def each_recursive(&block)\n tree.each_recursive(&block)\n end",
"def each(&block)\n root.each(&block)\n end",
"def is_leaf?\n\t\tself.part_map.empty?\n\tend",
"def is_leaf?\n self.children_count.zero?\n end",
"def leaf?\n @succ.length == 0\n end",
"def leaf(node, tag)\r\n end",
"def propagation_leafs\n trace.each_vertex.find_all { |v| trace.leaf?(v) }\n end",
"def leaf?\n leaves.count == 0\n end",
"def leaf?\n right - left == 1\n end",
"def leaf?\n @children.empty?\n end",
"def leaf?\n children.empty?\n end",
"def test_leaves_works\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(40, \"movie b\")\n tree.insert(60, \"movie c\")\n tree.insert(45, \"movie d\")\n tree.insert(20, \"movie e\")\n tree.insert(55, \"movie f\")\n tree.insert(80, \"movie g\")\n assert_equal 4, tree.leaves\n end",
"def leaf?\n self.children.size == 0\n end",
"def leaf?(r)\n r.children.empty?\n end",
"def test_traversal_post_2x_each_entry\n expected = [ 1, 4, 7, 6, 3, 12, 14, 10, 8 ].map {|x| x * 2}\n actual = @tree.traversal(:post, ->(x) { x * 2 })\n assert_equal expected,\n actual,\n \"actual: #{actual.inspect} should be #{expected.inspect}\"\n end",
"def has_children?\n !leaf?\n end",
"def leaf?\n @children.length.zero?\n end",
"def children_are_leaves?\n unless leaf?\n @children[0].leaf?\n end\n end",
"def leaf?\n level.zero?\n end",
"def each(node, &block); end",
"def leaf_count\n @leaf_count\n end",
"def each_child(&block)\n children.each do | child |\n yield(child)\n child.each_child &block unless child.leaf?\n end\n end",
"def each_hidden_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf unless leaf.visible\n end\n end",
"def each(&block)\n axis_iterator(:child).each(&block)\n end",
"def leaf?(sexp)\n list?(sexp) && depth(sexp) == 1\nend",
"def is_leaf?\n self.left_child == nil and\n self.right_child == nil\n end",
"def test_save_tree\n end",
"def leaf?\n new_record? || (rgt - lft == 1)\n end",
"def test_collect\n setup_test_tree\n collect_array = @root.collect do |node|\n node.content = \"abc\"\n node\n end\n collect_array.each {|node| assert_equal(\"abc\", node.content, \"Should be 'abc'\")}\n end",
"def each\n @children.each {|child| yield child}\n end",
"def verify\n 1.upto(@leaf_count - 1) do |node|\n next if @nodes[node] ==\n HashTree.node_hash(node, @nodes[HashTree.left_child(node)],\n @nodes[HashTree.right_child(node)])\n raise \"Tree integrity verification failed\" \n end\n self\n end",
"def each(&block)\n each_node([], @root, block)\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def each(current = @root, &block)\n return self.to_enum(:each) unless block_given?\n return if current.nil?\n\n each(current.left, &block)\n block.call(current.data)\n each(current.right, &block)\n end",
"def leaf?\n record.persisted? && if children.loaded? || tree.columns.counter_cache?\n # no SQL-queries here\n children.empty?\n else\n !children.exists?\n end\n end",
"def deep_each\n \n end",
"def leaf_lambda(node, this, nxt)\n set_lambda(this, nxt, 1)\n end",
"def each(&block)\n block.call(self)\n @child_array.each do |node|\n node.each(&block)\n end\n end",
"def test_children\n #puts \"---------------test_children-----------------\"\n t= {}\n\n batch11 = MyResource.new :batch11\n batch12 = MyResource.new :batch12\n batch21 = MyResource.new :batch21\n batch22 = MyResource.new :batch22\n pos1 = MyResource.new :pos1, [ batch11, batch12 ]\n pos2 = MyResource.new :pos2, [ batch21, batch22 ]\n order = MyResource.new :order, [pos1, pos2]\n\n GraphBuilder::Builder.build do |b|\n t[:order] = [ b.add(Thing0.new(order)) ]\n \n b.children do |pos|\n t[pos.name] = b.add Thing1.new(pos)\n b.children do |batch|\n b1 = b.add Thing11.new(batch)\n b2 = b.add Thing12.new(batch)\n t[batch.name] = [b1, b2]\n end\n end\n t[:order] << b.add( Thing2.new(order))\n end\n\n r = Thing.links(t.values.flatten)\n assert_instance_of Thing0, t[:order].first\n assert_instance_of Thing2, t[:order].last\n assert_instance_of Thing1, t[:pos1]\n assert_instance_of Thing1, t[:pos2]\n assert_instance_of Thing11, t[:batch11].first\n assert_instance_of Thing12, t[:batch12].last\n assert_instance_of Thing11, t[:batch21].first\n assert_instance_of Thing12, t[:batch22].last\n\n assert r.include? [t[:order].first,t[:pos1]]\n assert r.include? [t[:order].first,t[:pos2]]\n assert r.include? [t[:pos1],t[:batch11].first]\n assert r.include? [t[:pos1],t[:batch12].first]\n assert r.include? [t[:pos2],t[:batch21].first]\n assert r.include? [t[:pos2],t[:batch22].first]\n assert r.include? [t[:batch11].first,t[:batch11].last]\n assert r.include? [t[:batch12].first,t[:batch12].last]\n assert r.include? [t[:batch21].first,t[:batch21].last]\n assert r.include? [t[:batch22].first,t[:batch22].last]\n assert r.include? [t[:batch11].last,t[:order].last]\n assert r.include? [t[:batch12].last,t[:order].last]\n assert r.include? [t[:batch21].last,t[:order].last]\n assert r.include? [t[:batch22].last,t[:order].last]\n\n assert_equal 14, r.size\n end",
"def test_grid\n t = TreeShape.new(8)\n count = 0\n t.grid.each_index do |xi|\n t.grid[xi].each_index do |yi|\n count += 1\n end\n end\n assert_equal(count, t.height * t.width)\n end",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def iterate_children(ts, block, new_model)\n ts.children.each do |cs|\n # assumes there is only one element - could iterate instead but what case would that be?\n element = block.css(cs.selector).first\n\n handle_element(cs, element, new_model)\n end # end top selector children iteration\n end",
"def leaves\n descendants.where(arel_table[is_leaf_column_name].eq(true))\n end",
"def test_branch\n #puts \"---------------test_branch-----------------\"\n t1= nil\n t2 = nil\n t11 = nil\n t12 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12])\n assert_equal 4, r.size\n assert r.include? [t1,t11]\n assert r.include? [t1,t12]\n assert r.include? [t11,t2]\n assert r.include? [t12,t2]\n end",
"def each_with_level &block\n # @todo A bit of a hack that I would like to fix one day...\n @root.children.each do |element|\n recursive_each_with_level element, 1, block\n end\n end",
"def each_callback(&block)\n visit_node_for_callbacks(root, block)\n end",
"def test_display_list\n\n # Nothing selected\n list = Category.display_list\n assert_equal(1, list.size)\n assert_equal(categories(:category1), list[0])\n\n # Non-leaf selected\n list = Category.display_list(categories(:category1))\n assert_equal(6, list.size, list.inspect)\n assert_equal(categories(:category1), list[0])\n assert_equal(categories(:category2), list[1])\n assert_equal(categories(:category3), list[2])\n assert(list[0].selected)\n assert(!list[1].selected)\n assert(!list[2].selected)\n assert(!list[0].indented)\n assert(list[1].indented)\n assert(list[2].indented) \n\n # Leaf selected\n list = Category.display_list(categories(:category3))\n assert_equal(6, list.size)\n assert_equal(categories(:category1), list[0])\n assert_equal(categories(:category2), list[1])\n assert_equal(categories(:category3), list[2])\n assert(!list[0].selected)\n assert(!list[1].selected)\n assert(list[2].selected)\n assert(!list[0].indented)\n assert(list[1].indented)\n assert(list[2].indented)\n\n end",
"def is_a_leaf?\n self.left_child.nil? && self.right_child.nil?\n end",
"def test_children\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n assert(!@child3.is_leaf?, \"Should not be a leaf\")\n\n assert_equal(1, @child3.node_height, \"The subtree at Child 3 should have a height of 1\")\n for child in [@child1, @child2, @child4]\n assert_equal(0, child.node_height, \"The subtree at #{child.name} should have a height of 0\")\n end\n\n children = []\n for child in @root.children\n children << child\n end\n\n assert_equal(3, children.length, \"Should have three direct children\")\n assert(!children.include?(@root), \"Should not have root\")\n assert(children.include?(@child1), \"Should have child 1\")\n assert(children.include?(@child2), \"Should have child 2\")\n assert(children.include?(@child3), \"Should have child 3\")\n assert(!children.include?(@child4), \"Should not have child 4\")\n\n children.clear\n children = @root.children\n assert_equal(3, children.length, \"Should have three children\")\n end",
"def leaf?\n persisted? && right.to_i - left.to_i == 1\n end",
"def leafify(n)\n n.extend(Leaf)\n end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def new_leaf(payload, **kwargs)\n factory.leaf_node(payload, **kwargs)\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def each_ancestor # :nodoc:\n end",
"def each(node, &block)\n visit(node, &block)\n end",
"def each &block\n collection = self.collection\n if prefix = prefix_with_delim\n collection = collection.with_prefix(prefix)\n end\n collection.each(:delimiter => delimiter) do |member|\n case\n when member.respond_to?(:key)\n yield LeafNode.new(parent, member)\n when member.respond_to?(:prefix)\n yield BranchNode.new(parent, member,\n :delimiter => delimiter,\n :append => append?)\n end\n end\n nil\n end",
"def each_child_with_index\n end",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def test_siblings\n setup_test_tree\n\n # Lets first collect the siblings in an array.\n siblings = []\n @child1.siblings { |sibling| siblings << sibling}\n\n assert_equal(2, siblings.length, \"Should have two siblings\")\n assert(siblings.include?(@child2), \"Should have 2nd child as sibling\")\n assert(siblings.include?(@child3), \"Should have 3rd child as sibling\")\n\n siblings.clear\n siblings = @child1.siblings\n assert_equal(2, siblings.length, \"Should have two siblings\")\n\n siblings.clear\n @child4.siblings {|sibling| siblings << sibling}\n assert(siblings.empty?, \"Should not have any siblings\")\n\n siblings.clear\n siblings = @root.siblings\n assert_equal(0, siblings.length, \"Root should not have any siblings\")\n end",
"def each_with_index(&block)\n @tree.each_with_index(&block)\n end",
"def each_tree(&blk)\n # No block given? Return an enumerator.\n return to_enum(:each_tree) unless block_given?\n\n # Block given? Apply it.\n @assigns.each_value(&blk)\n end",
"def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end",
"def each_child_index\n end",
"def each_with_level(objects, &block)\n Iterator.new(objects).each_with_level(&block)\n end",
"def tree_map(&blk)\n children.inject([yield(self)]) do |trunk, child| \n trunk << child.tree_map(&blk)\n end\n end",
"def test_level\n assert_equal(0, @root.level, \"A root node's level is 0\")\n\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n\n setup_test_tree\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.level, \"Node #{child.name} should have level 1\")\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n end\n\n assert_equal(2, @child4.level, \"Child 4 should have level 2\")\n end",
"def iterating_block?(node); end",
"def each(*selector, &blk)\n children(*selector, &blk)\n self\n end",
"def leaf?\n children.where(parent_id: self.id).empty?\n end",
"def leaf?\n persisted? && if children_counter_cache_column\n self[children_counter_cache_column] == 0\n else\n children.count == 0\n end\n end",
"def visit_path_to_root(leaf_id)\n node = @leaf_count + leaf_id\n while node > 0\n yield node\n node = HashTree.parent(node)\n end\n self\n end",
"def test_preordered_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j, f, a, d, h, k, z]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n result_array = []\n j.preordered_each { |node| result_array << node.detached_copy}\n\n expected_array.each_index do |i|\n # Match only the names.\n assert_equal(expected_array[i].name, result_array[i].name)\n end\n end"
] |
[
"0.80726945",
"0.7618389",
"0.75051165",
"0.73378736",
"0.72592145",
"0.72518724",
"0.72058684",
"0.7045499",
"0.7045499",
"0.6691756",
"0.6641135",
"0.6595139",
"0.6587919",
"0.6518978",
"0.6484925",
"0.6477158",
"0.64397836",
"0.6378181",
"0.6264441",
"0.6232343",
"0.6207191",
"0.6183767",
"0.6154451",
"0.6142449",
"0.61170834",
"0.61107504",
"0.60790217",
"0.6064806",
"0.60534847",
"0.60493994",
"0.6034838",
"0.60191154",
"0.6014963",
"0.6002439",
"0.59837043",
"0.5962847",
"0.59448165",
"0.594155",
"0.59391683",
"0.5934756",
"0.5927466",
"0.5920149",
"0.59038526",
"0.59030527",
"0.5887186",
"0.5881324",
"0.5869788",
"0.58696026",
"0.5857072",
"0.5856944",
"0.5851865",
"0.5846635",
"0.5823581",
"0.58021784",
"0.5795405",
"0.57915455",
"0.57787216",
"0.57423294",
"0.5732106",
"0.57307833",
"0.57127863",
"0.5709369",
"0.570135",
"0.5678064",
"0.567793",
"0.5673217",
"0.56613386",
"0.56481886",
"0.5633496",
"0.5632704",
"0.56307274",
"0.5625512",
"0.56252897",
"0.5609062",
"0.5601436",
"0.56012475",
"0.5579953",
"0.55799395",
"0.5578832",
"0.55736184",
"0.5541742",
"0.55283225",
"0.5527649",
"0.55245316",
"0.5518336",
"0.5514562",
"0.55065966",
"0.5493031",
"0.54913276",
"0.5490738",
"0.5490693",
"0.5478623",
"0.5475174",
"0.54664457",
"0.54582196",
"0.5456901",
"0.5455755",
"0.54459953",
"0.5440018",
"0.5422922"
] |
0.7992356
|
1
|
Test the parent method.
|
def test_parent
setup_test_tree
assert_nil(@root.parent, "Root's parent should be nil")
assert_equal(@root, @child1.parent, "Parent should be root")
assert_equal(@root, @child3.parent, "Parent should be root")
assert_equal(@child3, @child4.parent, "Parent should be child3")
assert_equal(@root, @child4.parent.parent, "Parent should be root")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def should; super end",
"def calls_super # :nodoc:\n false\n end",
"def super_method; end",
"def expected_method; end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\" # change to altered() before calling the base class instance method with same name\n super() # base method with name name is call here\n puts \"CHILD, AFTER PARENT altered()\" # change to altered() after calling the base class instance method with same name\n end",
"def override()\n puts \"CHILD override()\"\n end",
"def child_condition; end",
"def inherited(base)\n\t\tbase.define_method teardown do\n\t\t\tsuper\n\t\tend\n\tend",
"def parent\n self.sample || self.test_subject\n end",
"def override() # Note that despite the module.override, this still overrides\r\n puts \"CHILD override()\"\r\n end",
"def self_test; end",
"def self_test; end",
"def call\n raise 'You must implement your own #call method in your subclass.'\n end",
"def test_Method_InstanceMethods_to_proc\n\t\tpass\n\tend",
"def inherited(base)\n base.define_method teardown do \n super\n end\n end",
"def inherited(base)\n base.define_method teardown do \n super\n end\n end",
"def inherited(base)\n base.define_method teardown do \n super\n end\n end",
"def inherited(base)\n base.define_method teardown do \n super\n end\n end",
"def run(*args) #:nodoc:\n return if @method_name == \"default_test\"\n super\n end",
"def process_hook\n fail 'child class to implement'\n end",
"def expect_before_nested_method_call; end",
"def evaluate( test )\n raise NoMethodError, \"You must override this method.\"\n end",
"def call\n raise \"Must subclass and implement call\"\n end",
"def inherited(base); end",
"def inherited(base)\n base.define_method teardown do\n super\n end\n end",
"def inherited(base)\n base.define_method teardown do\n super\n end\n end",
"def test_edit(pid)\n result = super\n if result\n return result\n else\n return test_edit_from_policy(pid)\n end\n end",
"def invoke\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n raise 'must be implemented in subclasses'\r\n end",
"def super_method \n \n puts \"Method of superclass\"\n end",
"def test_method\n end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\" \n super() # calls the super function so the program will use the function defined in the parent class\n puts \"CHILD, AFTER PARENT altered()\"\n end",
"def super_method \n puts \"Method of a superclass\"\n end",
"def foo(...)\n super(...)\nend",
"def call\n # implement in subclasses\n end",
"def test_modified\n parent = RoBaseIf.new( 'parent', '' )\n base = RoBaseIf.new( 'lab1', '' )\n base.parent = parent\n assert_equal false, parent.modified\n assert_equal false, base.modified\n base.value = 'A'\n assert_equal true, parent.modified\n assert_equal true, base.modified\n end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\"\n super()\n puts \"CHILD, AFTER PARENT altered()\"\n end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def stest_method_1(test); end",
"def invoke\n raise NotImplementedError, \"Author of subclass forgot to implement #invoke\"\n end",
"def derived_implementor?(parent, method_name)\n\t\t(self.method(method_name).to_s.match(/#{parent}[^:]/)) ? false : true\n\tend",
"def default_test\n info \"self: #{self}\"\n end",
"def testing\n # ...\n end",
"def display_parent_child_test_cases\n \n end",
"def special\n override\n end",
"def ok?\n raise \"Subclasses must implement this method.\"\n end",
"def method_missing(name, *args, &bl)\n @parent ? @parent.__send__(name, *args, &bl) : super\n rescue NoMethodError => ex\n name = ex.message[/`(.*?)'/, 1]\n ::Kernel.raise NoMethodError, \"Not found `#{name}` on #{self}\"\n end",
"def failure\n super\n end",
"def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end",
"def original_method; end",
"def call\n raise(CallNotDefined, \"Your subclass must define its own #call.\")\n end",
"def inherited(_sub)\n raise Error, \"cannot subclass #{self}\" unless self == Object\n end",
"def inherited(base)\n base.define_method :teardown do\n super\n end\n end",
"def super_before(&b)\n @expectation.super_before(&b)\n self\n end",
"def http_method\n raise \"Implement in child class\"\n end",
"def _parent; end",
"def test_entry\n raise \"Implement this method in your test class\"\n end",
"def call\n raise NotImplementedError, \"Expecting `call` method to have an expectation defined to assert.\"\n end",
"def run\n error \"Implement the run method in subclass #{self.class}\"\n 1\n end",
"def superclass() end",
"def ptest_method_1(test); end",
"def valid?\n raise Error::MethodShouldBeOverridenByExtendingClassError\n end",
"def method_missing(name, *args, &block)\n if parent && parent.respond_to?(name)\n block ||= lambda {} # captures self HERE\n parent.send(name, *args, &block)\n else\n super\n end\n end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def pass(description, result)\n raise \"Implement this in a sub-class\"\n end",
"def call\n raise NotImplementedError\n end",
"def call\n raise NotImplementedError\n end",
"def test_read(pid)\n result = super\n if result\n return result\n else\n return test_read_from_policy(pid)\n end\n end",
"def run\n begin\n self.class.roby_should_run(self, Roby.app)\n super\n rescue MiniTest::Skip => e\n puke self.class, self.name, e\n end\n end",
"def failure\n super\n end",
"def inherited(subclass); end",
"def verify?; raise NotImplementedError; end",
"def called_from; end",
"def called_from; end",
"def run\n raise \"Subclasses must implement this method.\"\n end",
"def covered?; end",
"def test_super options\n p \"Super Test Called\"\n return \"Super Test Called\"\n end",
"def method_missing(name, *args, &block)\n block ||= lambda {} # captures self HERE\n if @parent\n @parent.send(name, *args, &block)\n else\n super\n end\n end",
"def method_missing(name, *args, &block)\n block ||= lambda {} # captures self HERE\n if @parent\n @parent.send(name, *args, &block)\n else\n super\n end\n end",
"def test_case; end"
] |
[
"0.71102375",
"0.66954154",
"0.6500565",
"0.64474654",
"0.644199",
"0.64055",
"0.6377932",
"0.63137424",
"0.6306183",
"0.6255243",
"0.6233944",
"0.6233944",
"0.6193677",
"0.618211",
"0.617468",
"0.617468",
"0.617468",
"0.617468",
"0.61691517",
"0.6139561",
"0.6122296",
"0.6117378",
"0.6114446",
"0.61129993",
"0.610382",
"0.610382",
"0.60884386",
"0.60406166",
"0.6037105",
"0.60309505",
"0.6018867",
"0.60145295",
"0.6011937",
"0.59814066",
"0.5960989",
"0.5956615",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.59377104",
"0.5927983",
"0.5913354",
"0.59008783",
"0.58947504",
"0.58897454",
"0.5887048",
"0.5858223",
"0.58288026",
"0.58275026",
"0.58148664",
"0.5810354",
"0.5803754",
"0.5803268",
"0.57953364",
"0.5791537",
"0.5781352",
"0.5766689",
"0.5759126",
"0.57333523",
"0.57300186",
"0.57295597",
"0.5729277",
"0.57276726",
"0.57213444",
"0.5716613",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5707808",
"0.5694026",
"0.56932384",
"0.56932384",
"0.5688703",
"0.5679691",
"0.56795156",
"0.56787217",
"0.56769353",
"0.5667514",
"0.5667514",
"0.5662613",
"0.5645176",
"0.56420386",
"0.5627765",
"0.5627765",
"0.5624829"
] |
0.0
|
-1
|
Test the [] method.
|
def test_indexed_access
setup_test_tree
assert_equal(@child1, @root[0], "Should be the first child")
assert_equal(@child4, @root[2][0], "Should be the grandchild")
assert_nil(@root["TEST"], "Should be nil")
assert_nil(@root[99], "Should be nil")
assert_raise(ArgumentError) { @root[nil] }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [](*)\n raise NotImplementedError, '`#[]` method must be implemented'\n end",
"def [](index); end",
"def [](index)\n end",
"def [](index)\n end",
"def [](*) end",
"def [](index) # i.e. array style index lookup.\n end",
"def [](index); @data[index]; end",
"def [](value); end",
"def []( * ) # :nodoc:\n\t\treturn nil\n\tend",
"def [](param); end",
"def [](p1)\n #This is a stub, used for indexing\n end",
"def [](arg)\n end",
"def [](i)\n end",
"def [](i)\n end",
"def [](p1)\n #This is a stub, used for indexing\n end",
"def [](arg0)\n end",
"def [](expression); end",
"def [](*rest) end",
"def [](*rest) end",
"def [](p0) end",
"def [](p0) end",
"def [](posicion)\n end",
"def [](index)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def [] index\r\n @list[index]\r\n end",
"def test_0030_index_method\n @@log.debug \"test_0030_index_method starts\" if @@log.debug?\n # <<'s done in setup\n assert_equal(@aen,@list[0])\n assert_equal(@bsb,@list[1])\n assert_equal(@cab,@list[2])\n assert_equal(@dad,@list[3])\n #\n assert_nil(@list[9])\n @@log.debug \"test_0030_index_method ends\" if @@log.debug?\n end",
"def aget(index)\n end",
"def [](name); end",
"def [](name); end",
"def [](name); end",
"def [](name); end",
"def [](name); end",
"def [](index)\n self.__getitem__ index\n end",
"def test_index_access\n with_a_collection do\n assert_equal(@coll.first, @coll[0])\n end\n end",
"def [](idx)\n Ruby.primitive :array_aref\n end",
"def [](index)\n raise NoMethodError, %(this method must be redefined in subclasses)\n end",
"def test_index # Test the [] method\n assert_raise(ArgumentError) {@root[nil]}\n\n @root << @child1\n @root << @child2\n assert_equal(@child1.name, @root['Child1'].name, \"Child 1 should be returned\")\n assert_equal(@child1.name, @root[0].name, \"Child 1 should be returned\")\n assert_equal(@child1.name, @root[-2].name, \"Child 1 should be returned\") # Negative access also works\n assert_equal(@child1.name, @root[-(@root.children.size)].name, \"Child 1 should be returned\") # Negative access also works\n\n assert_equal(@child2.name, @root['Child2'].name, \"Child 2 should be returned\")\n assert_equal(@child2.name, @root[1].name, \"Child 2 should be returned\")\n assert_equal(@child2.name, @root[-1].name, \"Child 2 should be returned\") # Negative access also works\n\n assert_nil(@root['Some Random Name'], \"Should return nil\")\n assert_nil(@root[99], \"Should return nil\")\n assert_nil(@root[-(@root.children.size+1)], \"Should return nil\")\n assert_nil(@root[-3], \"Should return nil\")\n end",
"def [](p0, *rest) end",
"def [](p0, *rest) end",
"def [](*args)\n self\n end",
"def [](key)\n end",
"def [](key)\n end",
"def [](what)\n nil\n end",
"def [](key) ; @data[key] ; end",
"def get(index)\n \n end",
"def [](i); @x[i]; end",
"def access(n)\n true\n end",
"def [](index)\n return get(index)\n end",
"def [](index, name = T.unsafe(nil)); end",
"def [] (key)\n get(key)\n end",
"def [](name)\n\n end",
"def test_Arithmetic_Sample06\n assert_equal(1, 123[0])\n # TODO assert_equal(20, 123[3])\n # TODO assert_equal(3, 123[2])\n end",
"def []( index )\n feedme while !@done and index >= @truth.size\n return @truth[index]\n end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def test_array_index_0_equals_1\n\t\tassert_equal(1, anna_3_5[0])\n\tend",
"def [](index)\n get(index)\n end",
"def []=(*)\n raise NotImplementedError, '`#[]=` method must be implemented'\n end",
"def [](idx)\n send(idx)\n end",
"def [](index)\n set?(index)\n end",
"def test_arrayget_nil_on_nonexistent_index\n collection = Sketchup.active_model.pages\n expected = nil\n result = collection[collection.size]\n assert_equal(expected, result,\n 'Expected does not match result.')\n end",
"def [](index); @args[index] end",
"def [](index_or_name)\n end",
"def [](index_or_name)\n end",
"def [](index)\n all[index]\n end",
"def [](index)\n demand super(index)\n end",
"def [](key)\n puts \"STUB: [] in CacheMethods::Cache\"\n end",
"def [](sel); end",
"def [](n)\n @data[n]\n end",
"def [](index)\n @val[index]\n end",
"def test_14a_index_of_first_item\n puts \"test_14a_index_of_first_item\"\n ll = LinkedList.new()\n ll.push(\"foo\")\n ll.push(\"bar\")\n ll.push(\"good\")\n assert_equal(0, ll.index(\"foo\"))\n end",
"def [](index)\n cast get(index)\n end",
"def [](arg0, arg1, *rest)\n end",
"def [](*params)\n call(*params)\n end",
"def [](key, pos= 0, len= -1)\n end",
"def [](k) \n @data[k] \n end",
"def [](index)\n self.fetch[index]\n end",
"def at(index); end",
"def [](x)\n @data[x]\n end",
"def d\r\n a = [1, 2, 1.0]\r\n a[2]\r\nend",
"def [](i)\n \t@vector[i] \n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](*args) # :nodoc:\n call(*args)\n end",
"def test_instance_basic\n assert_equal('1', @ab[0])\n assert_equal('Assign', @ab[2])\n assert_equal('Buzz', @ab[4])\n assert_equal('AssignBuzz', @ab[14])\n assert_equal(nil, @ab[15])\n assert_equal(\n %w[1 2 Assign 4 Buzz\n Assign 7 8 Assign Buzz\n 11 Assign 13 14 AssignBuzz], @ab.results\n )\n assert_equal(3, @ab.Assign)\n assert_equal(5, @ab.Buzz)\n end"
] |
[
"0.7014241",
"0.70027465",
"0.69269663",
"0.69269663",
"0.68697435",
"0.68673015",
"0.6831208",
"0.6826385",
"0.6795721",
"0.6762816",
"0.6737938",
"0.67096496",
"0.6708499",
"0.6708499",
"0.6702766",
"0.66576606",
"0.66186357",
"0.6604641",
"0.6604641",
"0.6590126",
"0.6590126",
"0.6439321",
"0.6378111",
"0.6354464",
"0.63106775",
"0.62988263",
"0.62468797",
"0.62468797",
"0.62468797",
"0.62468797",
"0.62468797",
"0.6236415",
"0.6236195",
"0.62177193",
"0.6146956",
"0.61459357",
"0.61434335",
"0.61434335",
"0.6143319",
"0.6130621",
"0.6130621",
"0.6125434",
"0.6123547",
"0.61154455",
"0.61017823",
"0.6069906",
"0.6058272",
"0.60580194",
"0.6055852",
"0.6053",
"0.60511583",
"0.6051095",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.60335386",
"0.60297453",
"0.6016762",
"0.6007413",
"0.59956884",
"0.59684175",
"0.5964938",
"0.59337366",
"0.59337366",
"0.59293103",
"0.59223634",
"0.59194213",
"0.5918228",
"0.5906068",
"0.58943003",
"0.58931357",
"0.589181",
"0.5876955",
"0.58672416",
"0.5851452",
"0.5847699",
"0.5845913",
"0.58314896",
"0.5823622",
"0.581685",
"0.5802881",
"0.57913697",
"0.57913697",
"0.57913697",
"0.57913697",
"0.5790437",
"0.57876974"
] |
0.0
|
-1
|
Test the print_tree method.
|
def test_print_tree
setup_test_tree
#puts
#@root.print_tree
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_tree\n ''\n end",
"def print_tree\n if root.children\n puts \" - root : #{root.children.length} - \"\n root.children.each(&:print_node)\n puts ''\n end\n end",
"def printTree(options = {})\n # Set defaults\n options[:name] ||= true\n options[:content] ||= false\n \n result = \"\"\n \n options[:output] = result \n # Traverse tree and modify result by tacking on child names.\n printTraversal(options)\n \n puts result\n end",
"def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end",
"def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend",
"def print_tree(tree)\n\t\t\tif tree.is_leaf? and tree.depth > 0\n\t\t\t\tprint_line((\"|\\t\"*(tree.depth-1))+\"+------\"+tree.name)\n\t\t\telse\n\t\t\t\tprint_line((\"|\\t\"*tree.depth)+tree.name)\n\t\t\tend\n\t\t\ttree.children.each_pair do |name,child|\n\t\t\t\t\tprint_tree(child)\n\t\t\tend\n\t\tend",
"def print(node = root)\n puts %( ) * node.level + \"#{node}\"\n node.children.each do |child|\n print(child)\n end\n true\n end",
"def print\n node = root\n \n print_node(node, \"> \")\n end",
"def print_tree_perimeter(root)\n print \"print\"\nend",
"def print_tree(indent = 0, lines = [])\n lines << (\" \" * indent) + self.to_s\n @nodes.keys.sort.each do |reference|\n node = @nodes[reference]\n if node.is_a? APISpec::Namespace\n node.print_tree(indent + 1, lines)\n else\n lines << (\" \" * (indent + 1)) + \"#{reference} => #{node.to_s}\"\n end\n end\n lines.join(\"\\n\")\n end",
"def print_tree(d)\n \n print_tree(d['l']) if d.key?('l')\n print \"#{d['v']},\" if d.key?('v')\n print_tree(d['r']) if d.key?('r')\n \nend",
"def printout\n\t\t\n\t\tindex = 0\n\t\t\n\t\tdef small_loop (node, index)\n\t\t\t\n\t\t\tfor i in 0...index\n\t\t\t\tprint \" \"\n\t\t\tend\n\t\t\t\n\t\t\tputs node.name\n\t\t\tindex += 1\n\t\t\t\n\t\t\tif node.children.length > 0\n\t\t\t\tindex += 1\n\t\t\t\tnode.children.cycle(1) { |child| small_loop(child, index) }\n\t\t\tend\n\t\tend\n\t\t\n\t\tsmall_loop(@root, index)\n\tend",
"def printf(children=nil)\n fname = \"comparison.txt\"\n comparison_file = File.open(fname, \"w\")\n \n theight = tree_height(@root)\n for i in 1..theight do\n print_given_level(@root, i)\n end\n \n comparison_file.close\n\n end",
"def printTree(root = @root, indentation = \"\\n\")\r\n #print root the first time running mehtod, the rest will be printed as children\r\n puts \"#{indentation}#{root.value}\" if root == @root\r\n root.children.each do | child |\r\n puts \"#{indentation}\\t#{child.value}\\n\"\r\n #if there are children, again\r\n printTree(child, indentation + \"\\t\") if child.children.any?\r\n end\r\n end",
"def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end",
"def see_tree(tree)\n tree.each do |i|\n puts \"---------------\"\n puts \"Node: #{i.value}\"\n puts \"Parent: \" + i.find_parent[0].value.to_s if i.find_parent.count > 0\n puts \"Left Child: \" + i.find_left_child[0].value.to_s if i.find_left_child.count > 0\n puts \"Right Child: \" + i.find_right_child[0].value.to_s if i.find_right_child.count > 0\n end\nend",
"def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)",
"def print_result ptree, path_prefix\n puts dump(ptree, path_prefix)\n end",
"def print_tree(id)\n puts \"--------------------- Tree Record: #{NewYorkTrees::Tree.all[id].name} ---------------------\"\n puts \"\"\n puts \"Common Name:\"\n puts \"#{NewYorkTrees::Tree.all[id].name.ljust(25)}\"\n puts \"\"\n puts \"Scientific Name:\"\n puts \"#{NewYorkTrees::Tree.all[id].scientific_name.ljust(25)}\"\n puts \"\"\n puts \"Bark:\"\n puts \"#{NewYorkTrees::Tree.all[id].bark.ljust(25)}\"\n puts \"\"\n puts \"Twigs:\"\n puts \"#{NewYorkTrees::Tree.all[id].twigs.ljust(25)}\"\n puts \"\"\n puts \"Winter Buds:\"\n puts \"#{NewYorkTrees::Tree.all[id].winter_buds.ljust(25)}\"\n puts \"\"\n puts \"Leaves:\"\n puts \"#{NewYorkTrees::Tree.all[id].leaves.ljust(25)}\"\n puts \"\"\n puts \"Fruit:\"\n puts \"#{NewYorkTrees::Tree.all[id].fruit.ljust(25)}\"\n puts \"\"\n puts \"Distinguishing Features:\"\n puts \"#{NewYorkTrees::Tree.all[id].distinguishing_features.ljust(25)}\"\n puts \"\"\n puts \"---------------------Description---------------------\"\n\n puts \"#{NewYorkTrees::Tree.all[id].description}\"\n puts \"\"\n end",
"def print_tree(level = 0)\n if is_root?\n print \"\\n*\"\n else\n print \"|\" unless parent.is_root?\n print(' ' * (level - 1) * 4)\n print(is_root? ? \"+\" : \"|\")\n print \"---\"\n print(has_children? ? \"+\" : \">\")\n end\n\n if content\n content_hash = content.split(\"[\").first\n else\n content_hash = nil\n end\n\n puts \" #{content}\" + \" <Type: \" + (@node_type || \"no_type\") + \">\"\n\n children { |child| child.print_tree(level + 1)}\n end",
"def print_tree\n current = nil\n stack = Stack.new\n stack.push(@root)\n until stack.empty?\n current = stack.pop\n if current.parent.nil?\n puts current.tag\n else\n puts \"#{current.tag}\\t<=\\t#{current.parent.tag}\"\n end\n unless current.childs.size.zero?\n current.childs.reverse_each { |child| stack.push(child) }\n end\n end\n end",
"def test_tree_representation\n e =\n'ROOT (0.94)\n outlook => rainy (0.694)\n windy => TRUE (0.0)\n play => no (0.0)\n windy => FALSE (0.0)\n play => yes (0.0)\n outlook => overcast (0.694)\n play => yes (0.0)\n outlook => sunny (0.694)\n humidity => normal (0.0)\n play => yes (0.0)\n humidity => high (0.0)\n play => no (0.0)\n'\n assert_equal e, @tree.to_s\n end",
"def show_node(tree, node)\n print \"ID:#{node.id} Parent:#{node.parent} Keys:\"\n node.keys.each { |key| print \"[#{key}]\"}\n print \" Sub trees:\"\n node.sub_trees.each { |sub_tree| print \"-#{sub_tree}-\"}\n print \"\\n\"\n node.sub_trees.compact.each { |sub_tree| show_node(tree, tree.nodes[sub_tree])}\nend",
"def print(root)\n root_index = @tree.index(root)\n temp_tree = @tree[root_index..-1]\n temp_tree.each do |n|\n if n\n puts n.title + \": \" + n.rating.to_s\n end\n end\n end",
"def print_tree(out = $stdout)\n out.puts \"### LookupTable: #{name}\"\n out.puts \" Resource: #{resource_id}\"\n out.puts \" Required: #{table_fragment['Required']}\"\n out.puts \" Searchable: #{ table_fragment[\"Searchable\"] }\"\n out.puts \" Units: #{ table_fragment[\"Units\"] }\"\n out.puts \" ShortName: #{ table_fragment[\"ShortName\"] }\"\n out.puts \" LongName: #{ long_name }\"\n out.puts \" StandardName: #{ table_fragment[\"StandardName\"] }\"\n out.puts \"#### Types:\"\n\n lookup_types.each do |lookup_type|\n lookup_type.print_tree(out)\n end\n end",
"def print()\n current_node = @root_node\n while current_node != nil\n current_node.print()\n current_node = current_node.get_next()\n end\n end",
"def cmd_tree\n print_tree(Editor, 0)\n end",
"def printf(children=nil)\n children = [@root] if children.nil?\n grand_children = []\n children.each do |node|\n puts \"#{node.title}: #{node.rating}\\n\"\n grand_children.push(node.left) if node.left\n grand_children.push(node.right) if node.right\n end\n printf(grand_children) unless grand_children.empty?\n end",
"def print_paths\n path, counter = [], 0\n puts '************************ Tree Paths ***********************************'\n puts\n print_tree_paths(self.root, path, counter)\n puts\n puts '***********************************************************************'\n end",
"def printf\n output = []\n children = []\n output.push(\"#{@root.title}: #{@root.rating}\")\n if @root.left != nil\n children.push(@root.left)\n end\n if @root.right != nil\n children.push(@root.right)\n end\n children.each do |i|\n output.push(\"#{i.title}: #{i.rating}\")\n if i.left != nil\n children.push(i.left)\n end\n if i.right != nil\n children.push(i.right)\n end\n end\n puts output\n end",
"def level_order_print(tree)\n unless tree\n return\n end\n\n nodes = [tree]\n current_line_count = 1\n next_line_count = 0\n\n while nodes.length != 0\n current_node = nodes.shift\n current_line_count -= 1\n print current_node.key.to_s + ' '\n if current_node.left_child\n nodes.push(current_node.left_child)\n next_line_count += 1\n end\n if current_node.right_child\n nodes.push(current_node.right_child)\n next_line_count += 1\n end\n if current_line_count == 0\n # finished printing current level\n puts ''\n current_line_count = next_line_count\n next_line_count = current_line_count\n end\n end\nend",
"def test_print\r\n reader = GraphReader.new('whatever')\r\n reader.add_node(0, 'A', nil)\r\n assert_output(\"\\nNumber: 0\\nLetter: A\\nNeighbors: none\\n\") {reader.print_graph()}\r\n end",
"def printf(children=nil)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n puts(node.to_s)\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n end",
"def show_tree\n\tend",
"def printf(children=nil)\n results = Queue.new\n results.enq(@root)\n\n while !results.empty?\n node = results.deq\n \n puts \"#{node.title}: #{node.rating}\" if node.title \n\n results.enq(node.left) if node.left\n results.enq(node.right) if node.right\n end\n end",
"def printnodes(node, level)\r\n\theader(level)\r\n\tputs node\r\n\tif node.nodes?\r\n\t\ttemp = Array.new\r\n\t\tnode.nodes.each { |n|\r\n\t\t\tif n == nil\r\n\t\t\t\theader(level + 1)\r\n\t\t\t\tputs \":\"\r\n\t\t\telsif n == node.parent\r\n\t\t\t\theader(level + 1)\r\n\t\t\t\tputs node\r\n\t\t\telsif !temp.include?(n)\r\n\t\t\t\ttemp << n\r\n\t\t\telse\r\n\t\t\t\theader(level + 1)\r\n\t\t\t\tputs node\r\n\t\t\tend\r\n\t\t}\r\n\t\tif !temp.empty?\r\n\t\t\ttemp.each { |n|\r\n\t\t\t\tprintnodes(n, level + 1)\r\n\t\t\t}\r\n\t\tend\r\n\tend\r\nend",
"def print_tree(out = $stdout)\n out.puts \"Resource: #{id} (Key Field: #{key_field})\"\n rets_classes.each do |rets_class|\n rets_class.print_tree(out)\n end\n end",
"def show_binary_tree\n text = tree_levels_text_array\n puts \"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n puts \"\\nBinary Tree Display:\\n \"\n text.each { |row| puts \"\\n\" + row }\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n end",
"def print_tree(stream, indent=0)\n\t\t\tstream.puts summary(\"\\t\"*indent)\n\t\t\t@children.sort_by { |child_status|\n\t\t\t\tchild_status.get_rss_total\n\t\t\t}.each { |child_status|\n\t\t\t\t# recursively print trees for child statuses\n\t\t\t\tchild_status.print_tree(stream, indent+1)\n\t\t\t}\n\t\tend",
"def print_tree(array , item, level)\n items = array[item]\n unless items == nil\n indent = level > 0 ? sprintf(\"%#{level * 2}s\", \" \") : \"\"\n items.each do |e|\n puts \"#{indent}-#{e[:title]}\"\n print_tree(e, level + 1)\n end\n end\nend",
"def print_BST_in_order(root)\n if root.nil?\n return\n end\n print_BST_in_order(root.left)\n print \"#{root.value} \"\n print_BST_in_order(root.right)\nend",
"def print()\n puts @node_data.to_s\n end",
"def display_tree() \n list = []\n yield @tree.value\n left_child = @tree.left_child\n right_child = @tree.right_child\n\n list << left_child if left_child != nil\n list << right_child if right_child != nil\n\n loop do\n break if list.empty?\n node = list.shift\n yield node.value\n list << node.left_child if node.left_child != nil\n list << node.right_child if node.right_child != nil\n end\n end",
"def print_node\n puts \"Value of node #{node_value}. Childs of node: #{node_childs} \"\n end",
"def printf()\n #node object array\n children = []\n\n #info array\n arr = []\n arr.push(\"#{@root.title}: #{@root.rating}\")\n if @root.left != nil\n children.push(@root.left)\n end\n if @root.right != nil\n children.push(@root.right)\n end\n\n # adds nodes to children array AND pushes data to arr\n children.each do |node|\n if node.left != nil\n children.push(node.left)\n end\n if node.right != nil\n children.push(node.right)\n end\n arr.push(\"#{node.title}: #{node.rating}\")\n end\n\n puts arr\n end",
"def printf(children=nil)\n tree_output = [@root]\n tree_output.each do |node|\n tree_output.push(node.left) if !node.left.nil?\n tree_output.push(node.right) if !node.right.nil?\n end\n\n tree_output.each do |node|\n puts \"#{node.title}: #{node.rating}\"\n end\n\n end",
"def printf(children=nil)\n if @root.nil?\n return nil\n else\n for i in @root\n puts i\n end\n end\n end",
"def printf(children=nil)\n h = height(@root) + 1\n root = @root\n h.times do |i|\n self.print_level(root, i)\n end\n end",
"def printtree(n, t)\n if t.question==nil\n n.times {print \" \"}\n puts t.name\n else\n puts t.question\n printtree n+1, t.yes\n printtree n+1, t.no\n end\n end",
"def printf(children=nil)\n if children == nil\n children = [@root]\n end\n arr = []\n children.each do |ele|\n puts \"#{ele.title}: #{ele.rating}\"\n arr << ele.left if ele.left != nil\n arr << ele.right if ele.right != nil\n end\n if arr.size == 0\n return nil\n else\n printf(arr)\n end\n end",
"def print_tree(n, i = 0)\n i.times { print \" \" }\n puts \"+-#{n}\"\n $classtree[n].sort.each { |c| print_tree(c, i+2) }\nend",
"def printf(children=nil)\n\n new_children = []\n \n if children == nil\n children = [@root.left, @root.right]\n puts @root.title.to_s + \": \" + @root.rating.to_s\n end\n\n children.each do |ch|\n if ch != nil\n puts ch.title.to_s + \": \" + ch.rating.to_s\n new_children.push(ch.left) if ch.left\n new_children.push(ch.right) if ch.right\n end\n end\n\n if new_children != []\n printf(new_children)\n end\n end",
"def test_save_tree\n end",
"def printf(root=nil)# def printf(children=nil)\n if root == nil\n root = @root\n end\n node_array = []\n node_array.push(root)\n printf_breadth(node_array)\n end",
"def display\n puts @root.to_s + \" \" + \"=\" * 10\n traverse(@root,0) {|n, l| puts \" \"*l + \"node: #{n}\"}\n self\n end",
"def print_debug\n\t\tprint_divider\n\t\tputs \"Root Node: \\n\" + root.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Current Node: \\n\" + @current_node.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Attributes: \\n\" + attributes.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Children: \\n\" + children.to_xml\n\t\tprint_divider\n\tend",
"def print_tree(out = $stdout)\n out.puts \" #{long_value} -> #{value}\"\n end",
"def print_bst(root)\n return if root == nil\n puts root.value\n if root.left != nil\n puts \"Left of #{root.value}\"\n print_bst(root.left)\n end\n if root.right !=nil\n puts \"Right of #{root.value}\"\n print_bst(root.right)\n end\n end",
"def printf(children=nil)\n line = [@root]\n\n line.each do |i|\n puts \"#{i.title}: #{i.rating}\"\n if i.left\n line << i.left\n end\n if i.right\n line << i.right\n end\n end\n end",
"def print\n if self.length == 0\n puts \"empty\"\n else\n self.each { |node| puts node.data }\n end\n end",
"def inspect_tree(tree_hash=tree, indentation=\"\")\n parts = []\n tree_hash.each do |id, subtree|\n parts << indentation + nodes_by_id[id].to_s\n unless subtree.empty?\n parts << inspect_tree(subtree, indentation + \" \")\n end\n end\n\n unless parts.empty?\n parts.compact.join(\"\\n\")\n end\n end",
"def write_tree\n invoke(:write_tree)\n end",
"def printf\n queue = Queue.new\n queue.enq(@root)\n until queue.empty?\n value = queue.deq\n puts value unless value.title.nil?\n queue.enq(value.left) if value.left\n queue.enq(value.right) if value.right\n end\n end",
"def printf(list=[@root], output='')\n # remove front list item & add it to the output\n first = list.shift()\n print_string = first.title + ': ' + first.rating.to_s + \"\\n\"\n output << print_string\n # add its children to the back of the list\n if first.left\n list << first.left\n end\n if first.right\n list << first.right\n end\n # repeat until all nodes have been visited, then print output\n if list.empty?\n puts output\n return\n else\n printf(list, output)\n end\n end",
"def show_tree\n\t\t@root_node.show\n\tend",
"def printf(children=nil)\n text = \"\"\n if (self.root)\n queue = Queue.new\n queue.push(self.root)\n while (!queue.empty?)\n temp = queue.pop\n text << temp.title << \":\" << temp.rating.to_s\n if (temp.left)\n queue.push(temp.left)\n end\n if (temp.right)\n queue.push(temp.right)\n end\n text << \"\\n\"\n end\n puts text\n return\n end\n end",
"def print\n print_node(@head)\n end",
"def print(depth)\n spaces = \" \".freeze * depth\n \"#{left_stats} #{spaces} └── #{@node.name}\"\n end",
"def printf(children=nil)\n queue = [@root]\n result = \"\"\n\n until queue.empty?\n temp_root = queue.shift\n\n unless temp_root.left == nil\n queue << temp_root.left\n end\n unless temp_root.right == nil\n queue << temp_root.right\n end\n\n result << \"#{temp_root.title}: #{temp_root.rating}\\n\"\n end\n\n puts result\n end",
"def printf(children=nil)\n queue = [@root]\n\n queue.each do |current|\n puts \"#{current.value}\"\n if current.left && current.right\n queue << current.left << current.right\n elsif current.left\n queue << current.left\n elsif current.right\n queue << current.right\n end\n end\n end",
"def tree_print(tree, folder)\n str = \"\";\n tree.each do |key, value|\n if not value.is_a?(Hash)\n # page\n if value.name != \"Home\"\n str += \"<li><a href=\\\"/#{@wiki.base_path}#{value.url_path}\\\">#{value.name}</a></li>\"\n end\n else\n # folder\n subfolder = folder + \"/\" + key\n str += \"<li><a href=\\\"#{@wiki.base_path}#{subfolder}/\\\">#{key}</a>\"\n str += \"<ul>\"\n str += tree_print(value, subfolder)\n str += \"</ul>\"\n str += \"</li>\"\n end\n end\n return str\n end",
"def _display_tree(max_length=20, tabs='')\n\t\tif(@type != '')\n\t\t\tprint(tabs + \"[\" + @type + ((@param != '')? '(' + @param.to_s + ')': '') + \"]\\n\")\n\t\telse\n\t\t\tprint(tabs + \"[TEMPLATE:\" + @template.template_file + \"]\\n\")\n\t\tend\n\n\t\tfor content in @contents\n\t\t\tif(content.is_a?(SifterElement))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telsif(content.is_a?(SifterTemplate))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telse\n\t\t\t\tcontent.gsub!(/[\\r\\n]/, ' ')\n\t\t\t\tprint(tabs + \"\\t[TEXT:\" + content[0, max_length] + \"]\\n\")\n\t\t\tend\n\t\tend\n\tend",
"def printf(children=nil)\n toPrint = \"\"\n nextLine = []\n toPrint += \"#{@root.title}: #{@root.rating}\\n\"\n nextLine << @root.left if @root.left\n nextLine << @root.right if @root.right\n while nextLine.length > 0\n placeholder = []\n nextLine.each do |x|\n title = x.title\n rating = x.rating\n toPrint += \"#{title}: #{rating}\\n\"\n placeholder << x.left if x.left\n placeholder << x.right if x.right\n end\n nextLine = placeholder\n end\n print toPrint\n end",
"def printf(children=nil)\n queue = Queue.new\n queue.enq(@root)\n while !queue.empty?\n value = queue.deq\n puts \"#{value.title}: #{value.rating}\\n\"\n queue.enq(value.left) if value.left\n queue.enq(value.right) if value.right\n end\n end",
"def printf(children=nil)\n queue = [@root]\n result = []\n while queue.length > 0\n new_root = queue.shift\n if new_root.left != nil\n queue.push(new_root.left)\n end\n if new_root.right != nil\n queue.push(new_root.right)\n end\n result.push(\"#{new_root.title}: #{new_root.rating}\")\n end\n result.each {|x| puts x}\n end",
"def print(node = @root, prefix = '', is_left = true)\n if node.nil?\n return\n end\n\n print(node.right_node, \"#{prefix}#{is_left ? '│ ' : ' '}\", false) if node.right_node\n puts \"#{prefix}#{is_left ? '└── ' : '┌── '}#{node.value}\"\n print(node.left_node, \"#{prefix}#{is_left ? ' ' : '│ '}\", true) if node.left_node\n end",
"def printf(children=nil)\n \n queue = [@root]\n output = \"\"\n \n until queue.empty?\n traversal = queue.shift\n queue << traversal.left if traversal.left\n queue << traversal.right if traversal.right\n \n output += \"#{traversal.title}: #{traversal.rating}\\n\"\n end\n \n puts output\n end",
"def show_tree\n htmltree = \"\"\n self.each { |node| \n htmltree += \"<li><a href='#{normalize(node.name)}'>\"\n htmltree += ' ' * node.node_depth * 3\n htmltree += \"#{node.name}</a></li>\\n\"\n }\n htmltree\n end",
"def print_BST_by_layer(root)\n puts \"print BST rooted at #{root.value} by layer\" if $debug\n print_queue = Array.new\n level_queue = Array.new\n print_queue.push root\n level_queue.push 1\n prev_level = 1\n while !print_queue.empty?\n bst_node = print_queue.first\n print_queue.delete_at 0\n cur_level = level_queue.first\n level_queue.delete_at 0\n print \"\\n\" if cur_level != prev_level\n print \"#{bst_node.value} \"\n prev_level = cur_level\n if !bst_node.left.nil?\n print_queue.push bst_node.left\n level_queue.push cur_level+1\n end\n if !bst_node.right.nil?\n print_queue.push bst_node.right\n level_queue.push cur_level+1\n end\n end\nend",
"def print(children=nil)\n queue = Queue.new\n #Add the root to the queue\n queue.enq(@root)\n #loop while queue isn't empty\n while !queue.empty?\n #take and print value in queue\n value = queue.deq\n puts \"#{value.title}: #{value.rating}\" if !value.title.nil?\n #search left then right for new queue item\n queue.enq(value.left) if value.left\n queue.enq(value.right) if value.right\n end\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def pretty_print(node = @root, prefix = '', is_left = true)\n pretty_print(node.right_child, \"#{prefix}#{is_left ? '│ ' : ' '}\", false) if node.right_child\n puts \"#{prefix}#{is_left ? '└── ' : '┌── '}#{node.data}\"\n pretty_print(node.left_child, \"#{prefix}#{is_left ? ' ' : '│ '}\", true) if node.left_child\n end",
"def pretty_print(node = @root, prefix = '', is_left = true)\n pretty_print(node.right_child, \"#{prefix}#{is_left ? '│ ' : ' '}\", false) if node.right_child\n puts \"#{prefix}#{is_left ? '└── ' : '┌── '}#{node.data}\"\n pretty_print(node.left_child, \"#{prefix}#{is_left ? ' ' : '│ '}\", true) if node.left_child\n end",
"def runTest()\n\tareaWidth = rand(80..140)\n\tareaHeight = rand(40..80)\n\tsubdivisions = rand(3..6)\n\tbspTree = Tree.new([areaWidth, areaHeight, subdivisions])\n\tcreateTextOutput(bspTree, areaWidth, areaHeight, subdivisions)\nend",
"def output_tree(element, indent = '')\n\t\t\t\tputs \"#{indent}#{element.class}: #{element.text_value}\"\n\t\t\t\t(element.elements || []).each do |e|\n\t\t\t\t\toutput_tree(e, \"#{indent} \")\n\t\t\t\tend\n\t\t\tend",
"def printf(children=nil)\n list = [@root]\n while !list.empty?\n if list[0].left\n list.push(list[0].left)\n end\n if list[0].right\n list.push(list[0].right)\n end\n puts \"#{list[0].title}: #{list[0].rating}\\n\"\n list.shift\n end\n end",
"def print_non_leaf(node)\n # printer function for .hrl .erl non-leaf elements declarations\n if !@regtally.has?(node)\n node_name = node.s_u_name\n case node.kind\n when \"struct\", \"array\"\n @hrl << \"-record('#{node_name}',{\" \n @erl << \"-define('#{node_name}',\\n\" if node.level == 0\n @erl << \"-define('#{node_name}'(Path),\\n\" if node.level > 0\n @erl << \"#{@@ind[0]}{struct,'#{node_name}',\\n\"\n when \"union\"\n # @hrl << \"-record('#{node_name}',{\" \n @erl << \"-define('#{node_name}'(Path),\\n\"\n @erl << \"#{@@ind[0]}{union,'#{node_name}',\\n\" \n @erl << \"#{@@ind[0]} {?MODULE,union_type,[Path]},\\n\"\n end\n node.children.each do |n|\n print_element(n)\n end\n @regtally.add(node)\n end\n end",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def print_automation_objects(indent_level, hierarchy)\n case hierarchy.position\n when 'root'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.root)\")\n when 'parent'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.parent)\")\n when 'object'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.object)\")\n else\n print_line(indent_level, \"#{hierarchy.obj_name}\")\n end\n indent_level += 1\n hierarchy.children.each do |child|\n print_automation_objects(indent_level, child)\n end\nend",
"def PrintOutlineTree (item)\n\twhile item.IsValid() do\n\t\tPrintIndent(item)\n\t\tif item.IsOpen()\n\t\t\tprint( \"- \" + item.GetTitle() + \" ACTION -> \")\n\t\telse\n\t\t\tprint(\"+ \" + item.GetTitle() + \" ACTION -> \")\n\t\tend\n\t\n\t\t# Print Action\n\t\taction = item.GetAction()\n\t\tif action.IsValid()\n\t\t\tif action.GetType() == Action::E_GoTo\n\t\t\t\tdest = action.GetDest()\n\t\t\t\tif dest.IsValid()\n\t\t\t\t\tpage = dest.GetPage()\n\t\t\t\t\tputs \"GoTo Page #\" + page.GetIndex().to_s()\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Not a 'GoTo' action\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"NIL\"\n\t\tend\n\t\n\t\t# Recursively print children sub-trees \n\t\tif item.HasChildren() \n\t\t\tPrintOutlineTree(item.GetFirstChild())\n\t\tend\n\t\titem = item.GetNext()\n\tend\nend",
"def print_tree_size()\n\t\tputs \"Total size for #{@folder_walker.folder} is #{commify(@folder_walker.total_size)}\"\n\tend",
"def render(node = nil)\n elt = node | tree\n puts \"\\nNodes: #{elt.body.count}\"\n puts \"\\nAttributes:\"\n elt.attrs.each{ |k, v| puts(\"#{k}: #{v}\") }\n children = elt.body.select{ |i| i.is_a?(Node) }\n puts \"\\nChildren: #{children.each{ |c| render(c) }}\"\n\n\n end",
"def printf(children=nil)\n if children.nil?\n children = [@root]\n end\n next_row = []\n children.each do |child|\n puts \"#{child.title}: #{child.rating}\"\n next_row.push(child.left) if !child.left.nil?\n next_row.push(child.right) if !child.right.nil?\n end\n if next_row.size == 0\n nil\n else\n printf(next_row)\n end\n end",
"def print_tree filename, function_name, only_structure\n code = IO.read filename\n begin\n parser = YARD::Parser::Ruby::RubyParser.parse code\n puts get_root_sexp(parser.ast, function_name, only_structure)\n rescue YARD::Parser::ParserSyntaxError => e\n puts '( root ( ' + function_name + ' ) )'\n end \nend",
"def run_tests\n desc = 'valid full tree'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(30)\n right = tree.insert_right(70)\n left.insert_left(10)\n left.insert_right(40)\n right.insert_left(60)\n right.insert_right(80)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\n\n desc = 'both subtrees valid'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(30)\n right = tree.insert_right(80)\n left.insert_left(20)\n left.insert_right(60)\n right.insert_left(70)\n right.insert_right(90)\n result = binary_search_tree?(tree)\n assert_false(result, desc)\n\n desc = 'descending linked list'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(40)\n left_left = left.insert_left(30)\n left_left_left = left_left.insert_left(20)\n left_left_left.insert_left(10)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\n\n desc = 'out of order linked list'\n tree = BinaryTreeNode.new(50)\n right = tree.insert_right(70)\n right_right = right.insert_right(60)\n right_right.insert_right(80)\n result = binary_search_tree?(tree)\n assert_false(result, desc)\n\n desc = 'one node tree'\n tree = BinaryTreeNode.new(50)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\nend",
"def _display_tree(max_length=20, tabs='')\n\t\treturn @contents._display_tree(max_length, tabs)\n\tend",
"def show()\n printed = \"IPv4 Tree\\n---------\\n\"\n list4 = dump_children(@v4_root)\n list6 = dump_children(@v6_root)\n\n list4.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc}\\n\"\n end\n\n printed << \"\\n\\nIPv6 Tree\\n---------\\n\" if (list6.length != 0)\n\n list6.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc(:Short => true)}\\n\"\n end\n\n return(printed)\n end",
"def output_hierarchy(output=$stdout)\n hierarchy.print_tree(output)\n end",
"def pretty_print(node = @root, prefix = '', is_left = true)\n pretty_print(node.right_node, \"#{prefix}#{is_left ? '│ ' : ' '}\", false) if node.right_node\n puts \"#{prefix}#{is_left ? '└── ' : '┌── '}#{node.data}\"\n pretty_print(node.left_node, \"#{prefix}#{is_left ? ' ' : '│ '}\", true) if node.left_node\n end",
"def pretty_print(node = @root_node, prefix = '', is_left = true)\n pretty_print(node.right_node, \"#{prefix}#{is_left ? '│ ' : ' '}\", false) if node.right_node\n puts \"#{prefix}#{is_left ? '└── ' : '┌── '}#{node.data}\"\n pretty_print(node.left_node, \"#{prefix}#{is_left ? ' ' : '│ '}\", true) if node.left_node\n end"
] |
[
"0.7902457",
"0.7844856",
"0.76276535",
"0.76085335",
"0.7580548",
"0.75174874",
"0.73933315",
"0.7332164",
"0.7263764",
"0.72026175",
"0.71303356",
"0.71237785",
"0.71031094",
"0.7033289",
"0.70139384",
"0.69903165",
"0.6978808",
"0.69728065",
"0.69462276",
"0.67919517",
"0.67672706",
"0.67450726",
"0.67225397",
"0.67026937",
"0.6694438",
"0.66751957",
"0.6669133",
"0.6608757",
"0.6608528",
"0.6606948",
"0.6598426",
"0.65945137",
"0.6581486",
"0.65674096",
"0.6551565",
"0.6516293",
"0.65161425",
"0.6506089",
"0.6505552",
"0.6496667",
"0.6477464",
"0.64622974",
"0.6460678",
"0.64527166",
"0.6445853",
"0.6439613",
"0.63962567",
"0.6390464",
"0.63890344",
"0.6385771",
"0.63843375",
"0.63639957",
"0.6361296",
"0.6341011",
"0.63364357",
"0.6325698",
"0.63245803",
"0.63151103",
"0.6308183",
"0.630715",
"0.62955284",
"0.6295336",
"0.6287553",
"0.6281977",
"0.6274368",
"0.6274208",
"0.6242447",
"0.6236627",
"0.6218874",
"0.62185025",
"0.620851",
"0.62016",
"0.61965233",
"0.6195792",
"0.6194509",
"0.6184263",
"0.6182131",
"0.6178455",
"0.61685956",
"0.6165203",
"0.6146537",
"0.6144753",
"0.6144753",
"0.6082124",
"0.6075232",
"0.6065884",
"0.6065055",
"0.60639006",
"0.60616153",
"0.60540605",
"0.6053679",
"0.6052075",
"0.604332",
"0.6041991",
"0.60274285",
"0.6025053",
"0.60186625",
"0.601704",
"0.59946615",
"0.5988928"
] |
0.9064362
|
0
|
Tests the binary dumping mechanism with an Object content node
|
def test_marshal_dump
# Setup Test Data
test_root = Tree::TreeNode.new("ROOT", "Root Node")
test_content = {"KEY1" => "Value1", "KEY2" => "Value2" }
test_child = Tree::TreeNode.new("Child", test_content)
test_content2 = ["AValue1", "AValue2", "AValue3"]
test_grand_child = Tree::TreeNode.new("Grand Child 1", test_content2)
test_root << test_child << test_grand_child
# Perform the test operation
data = Marshal.dump(test_root) # Marshal
new_root = Marshal.load(data) # And unmarshal
# Test the root node
assert_equal(test_root.name, new_root.name, "Must identify as ROOT")
assert_equal(test_root.content, new_root.content, "Must have root's content")
assert(new_root.is_root?, "Must be the ROOT node")
assert(new_root.has_children?, "Must have a child node")
# Test the child node
new_child = new_root[test_child.name]
assert_equal(test_child.name, new_child.name, "Must have child 1")
assert(new_child.has_content?, "Child must have content")
assert(new_child.is_only_child?, "Child must be the only child")
new_child_content = new_child.content
assert_equal(Hash, new_child_content.class, "Class of child's content should be a hash")
assert_equal(test_child.content.size, new_child_content.size, "The content should have same size")
# Test the grand-child node
new_grand_child = new_child[test_grand_child.name]
assert_equal(test_grand_child.name, new_grand_child.name, "Must have grand child")
assert(new_grand_child.has_content?, "Grand-child must have content")
assert(new_grand_child.is_only_child?, "Grand-child must be the only child")
new_grand_child_content = new_grand_child.content
assert_equal(Array, new_grand_child_content.class, "Class of grand-child's content should be an Array")
assert_equal(test_grand_child.content.size, new_grand_child_content.size, "The content should have same size")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def can_be_fully_dumped?(object)\n begin\n Marshal.dump(object)\n true\n rescue TypeError, IOError\n false\n end\n end",
"def dump(object)\n raise NotImplementedError, \"#{self.class} must implement #dump\"\n end",
"def structure_dump() end",
"def marshal_dump; end",
"def _dump\n self.contents\n end",
"def dump(object)\n dumper(object).dump\n end",
"def dump(object)\n raise NotImplementedError, \"#{self.class}#dump is not implemented\"\n end",
"def _dump() end",
"def check_binary(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"binary\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def serialize(_object, data); end",
"def serialize(_object, data); end",
"def can_dump?(p_object)\n begin\n Marshal.dump(p_object)\n return true\n rescue TypeError\n return false\n rescue\n return false\n end\n end",
"def serialize(object, data); end",
"def test_binary\n mode = is19? ? \"rb:ascii-8bit\" : \"rb\"\n bin_file_content = File.open(\"#{FIXTURES}/favicon.ico\", mode).read\n c = WDDX.load(WDDX::Binary.new(bin_file_content).to_wddx)\n assert_equal bin_file_content, c.data.bin_data \n end",
"def test_a_binary\n binary = @wddx.data[\"aBinary\"]\n assert binary.kind_of?(WDDX::Binary)\n assert_equal \"MIIBJASHETAS\", binary.encode \n end",
"def inspect\n \"<BSON::Binary:0x#{object_id} type=#{type} data=0x#{data[0, 8].unpack1('H*')}...>\"\n end",
"def dump(object)\n adapter_dump(object)\n end",
"def serialize(object) end",
"def dump( obj, &block )\n f = File.open( get_unique_filename, 'w' )\n\n serialized = serialize( obj )\n f.write( serialized )\n\n block.call( serialized ) if block_given?\n\n f.path\n ensure\n f.close\n end",
"def dump(object)\n internal = ::Riak::Serializers.serialize(content_type, object)\n encrypt(internal)\n end",
"def _dump()\n #This is a stub, used for indexing\n end",
"def test_to_bytes\n vote = {\n type: :vote,\n voter: 'xeroc',\n author: 'xeroc',\n permlink: 'piston',\n weight: 10000,\n extensions: [],\n }\n \n @transaction.operations << vote\n refute_nil bytes = @transaction.send(:to_bytes)\n hex = hexlify(bytes)\n \n # Here, we're going to take apart our contrived serialization so we can\n # verify each substring individually.\n \n chain_id = hex[0..63]\n ref_block_num = hex[64..67]\n ref_block_prefix = hex[68..75]\n exp = hex[76..83]\n op_len = hex[84..85]\n op_id = hex[86..87]\n voter = hex[88..99]\n author = hex[100..111]\n permlink = hex[112..125]\n weight = hex[126..129]\n extensions = hex[130..131]\n \n hex_segments = {\n chain_id: chain_id, ref_block_num: ref_block_num,\n ref_block_prefix: ref_block_prefix, exp: exp, op_len: op_len,\n op_id: op_id, voter: voter, author: author, permlink: permlink,\n weight: weight, extensions: extensions\n }\n \n # This example serialization was documented by xeroc:\n # https://steemit.com/steem/@xeroc/steem-transaction-signing-in-a-nutshell\n example_hex = 'bd8c5fe26f45f179a8570100057865726f63057865726f6306706973746f6e102'\n assert hex.include?(example_hex), 'expect example_hex in our result'\n \n # Later correction by xeroc:\n # https://steemit.com/steem/@xeroc/steem-transaction-signing-in-a-nutshell#@xeroc/re-steem-transaction-signing-in-a-nutshell-20160901t151404\n example_hex2 = 'bd8c5fe26f45f179a8570100057865726f63057865726f6306706973746f6e102700'\n assert hex.include?(example_hex2), 'expect example_hex2 in our result'\n \n # The only thing that should remain if we remove the second example is the\n # chain_id.\n remaining_hex = hex.gsub example_hex2, ''\n assert_equal Radiator::ChainConfig::NETWORKS_HIVE_CHAIN_ID,\n remaining_hex, 'expect nothing but the chain_id'\n \n # Here, we're going to take apart our contrived serialization so we can\n # verify each substring.\n \n assert_equal Radiator::ChainConfig::NETWORKS_HIVE_CHAIN_ID,\n hex_segments[:chain_id], 'expect chain_id'\n assert_equal 'bd8c', hex_segments[:ref_block_num], 'expect ref_block_num'\n assert_equal '5fe26f45', hex_segments[:ref_block_prefix], 'expect ref_block_prefix'\n assert_equal 'f179a857', hex_segments[:exp], 'expect exp'\n assert_equal '01', hex_segments[:op_len], 'expect op_len'\n assert_equal '00', hex_segments[:op_id], 'expect op_id'\n assert_equal '057865726f63', hex_segments[:voter], 'expect voter'\n assert_equal '057865726f63', hex_segments[:author], 'expect author'\n assert_equal '06706973746f6e', hex_segments[:permlink], 'expect permlink'\n assert_equal '1027', hex_segments[:weight], 'expect weight'\n assert_equal '00', hex_segments[:extensions], 'expect extensions'\n assert_equal hex, hex_segments.values.join\n end",
"def dump(obj, io)\n io.puts obj.send(inspect_method)\n end",
"def marshal_dump\n dump\n end",
"def dump() end",
"def test_truth\r\n assert_kind_of Binary, @binary\r\n end",
"def _dump\n end",
"def test_serialization\n # TODO: test serialization methods\n end",
"def marshall_dump\n end",
"def dump contents;\r\n # p contents\r\n @dumps = Array.new unless @dumps \r\n @dumps << contents \r\n end",
"def marshall_dump\n end",
"def test_object\n # encoded as object, shows up\n blob = <<ICS\nBEGIN:VCALENDAR\nBEGIN:VEVENT\nUID:foobar11\nDTSTART:20110101T210000Z\nDURATION:PT1H\nEND:VEVENT\nEND:VCALENDAR\nICS\n\n assert_free_busy_report(\n 'FREEBUSY:20110101T210000Z/20110101T220000Z',\n Tilia::VObject::Reader.read(blob)\n )\n end",
"def test_content\n pers = Person::new(\"John\", \"Doe\")\n @root.content = pers\n assert_same(pers, @root.content, \"Content should be the same\")\n end",
"def marshal_load(serialised); end",
"def load(content) # :nodoc:\n Marshal::load(content)\n end",
"def _load(dump)\n self.contents = dump\n end",
"def undumpable?(object)\n !can_be_fully_dumped?(object) && !can_be_dumped_as_copy?(object)\n end",
"def write_object(id, raw)\n if @entries.length > @btreedb.max_blob_size\n # The blob has reached the maximum size. Replace the blob with a BTree\n # node directory and distribute the blob entires into the sub-blobs of\n # the new BTree node.\n split_blob\n # Insert the passed object into the newly created BTree node.\n @btreedb.put_raw_object(raw, id)\n else\n bytes = raw.bytesize\n crc32 = Zlib.crc32(raw, 0)\n start_address = reserve_bytes(id, bytes, crc32)\n if write_to_blobs_file(raw, start_address) != bytes\n PEROBS.log.fatal 'Object length does not match written bytes'\n end\n write_index\n end\n end",
"def content\n object = FakeObject.new\n end",
"def can_be_dumped_as_copy?(object)\n begin\n copy = object.class.allocate\n Marshal.dump(copy)\n true\n rescue StandardError\n false\n end\n end",
"def marshal_dump\n data\n end",
"def save_dataE(obj, filename) \r\n File.open(filename, \"wb\") { |f|\r\n Marshal.dump(obj, f)\r\n }\r\nend",
"def blob; end",
"def blob; end",
"def put_raw_object(content, type)\n size = content.length.to_s\n LooseStorage.verify_header(type, size)\n \n header = \"#{type} #{size}\\0\"\n store = header + content\n \n sha1 = Digest::SHA1.hexdigest(store)\n path = @directory+'/'+sha1[0...2]+'/'+sha1[2..40]\n \n if !File.exists?(path)\n content = Zlib::Deflate.deflate(store)\n \n FileUtils.mkdir_p(@directory+'/'+sha1[0...2])\n File.open(path, 'w') do |f|\n f.write content\n end\n end\n return sha1\n end",
"def dump\n @@fields.each { |field| @contents[field] = send(field) } \n @contents\n end",
"def test_s_dump_load4\n b1 = 123456789012345678901234567890\n b2 = -123**99\n b3 = 2**32\n assert_equal(b1, Marshal.load(Marshal.dump(b1)))\n assert_equal(b2, Marshal.load(Marshal.dump(b2)))\n assert_equal(b3, Marshal.load(Marshal.dump(b3)))\n end",
"def send_object obj\n data = serializer.dump(obj)\n send_data [data.respond_to?(:bytesize) ? data.bytesize : data.size, data].pack('Na*')\n end",
"def read_binary_object(fname,fd)\n # first: read the marker byte\n buff = fd.read(1)\n\n object_length = buff.unpack(\"C*\")\n object_length = object_length[0] & 0xF\n\n buff = buff.unpack(\"H*\")\n object_type = buff[0][0].chr\n\n if(object_type != \"0\" && object_length == 15) then\n object_length = read_binary_object(fname,fd)\n object_length = object_length.value\n end\n\n retval = nil\n case object_type\n when '0' then # null, false, true, fillbyte\n retval = read_binary_null_type(object_length)\n when '1' then # integer\n retval = read_binary_int(fname,fd,object_length)\n when '2' then # real\n retval = read_binary_real(fname,fd,object_length)\n when '3' then # date\n retval = read_binary_date(fname,fd,object_length)\n when '4' then # data\n retval = read_binary_data(fname,fd,object_length)\n when '5' then # byte string, usually utf8 encoded\n retval = read_binary_string(fname,fd,object_length)\n when '6' then # unicode string (utf16be)\n retval = read_binary_unicode_string(fname,fd,object_length)\n when 'a' then # array\n retval = read_binary_array(fname,fd,object_length)\n when 'd' then # dictionary\n retval = read_binary_dict(fname,fd,object_length)\n end\n\n return retval\n end",
"def load(dump)\n loader(dump).object\n end",
"def demarshal_object(blob)\n Marshal.load(blob)\n end",
"def p(obj)\n @contents << obj.inspect << \"\\n\"\n end",
"def dumper(object)\n Dumper.new(object)\n end",
"def deserialize()\n mem_buf = File.new('test/basic_complex_test/ruby_test/bin.babel.rb').binmode\n end",
"def put_object(type, content)\n data = \"#{type} #{content.length}\\0#{content}\"\n id = sha(data)\n path = object_path(id)\n\n unless File.exists?(path)\n FileUtils.mkpath(File.dirname(path))\n open(path, 'wb') do |f|\n f.write Zlib::Deflate.deflate(data)\n end\n end\n\n id\n end",
"def _dump(*args)\n raise \"not implemented yet\"\n end",
"def test_binary\n base64_binary_xml = <<EOF\n <llsd>\n <binary>dGhlIHF1aWNrIGJyb3duIGZveA==</binary>\n </llsd>\nEOF\n\n # <binary/> should return blank binary blob... in ruby I guess this is just nil\n\n assert_equal 'dGhlIHF1aWNrIGJyb3duIGZveA==', LLSD.parse(base64_binary_xml)\n end",
"def object_data(path)\n blob = path_to_object(path)\n return nil if (not blob) || (blob.kind_of? Grit::Tree)\n blob.kind_of?(Grit::Blob) ? blob.data : blob\n end",
"def copy object\r\n\tMarshal.load(Marshal.dump(object))\r\nend",
"def print_bitstream(d)\n item = d.getParentObject\n handle = item.nil? ? 'no-handle' : item.getHandle\n puts [d.getSize, d.getID, handle, d.getName].join(\"\\t\")\nend",
"def dump_info(my_object, my_object_name)\n self.dump_attributes(my_object, my_object_name)\n self.dump_associations(my_object, my_object_name)\n self.dump_virtual_columns(my_object, my_object_name)\n end",
"def assert_has_stream_for(object); end",
"def __bson_dump__(io, key)\n io << Types::OBJECT_ID\n io << key.to_bson_cstring\n io << data\n end",
"def check_marshallable(object, stack = ValueSet.new)\n if !object.kind_of?(DRbObject) && object.respond_to?(:each) && !object.kind_of?(String)\n if stack.include?(object)\n Distributed.warn \"recursive marshalling of #{obj}\"\n raise \"recursive marshalling\"\n end\n\n stack << object\n begin\n object.each do |obj|\n marshalled = begin\n check_marshallable(obj, stack)\n rescue Exception\n raise TypeError, \"cannot dump #{obj}(#{obj.class}): #{$!.message}\"\n end\n\n \n if Marshal.load(marshalled).kind_of?(DRb::DRbUnknown)\n raise TypeError, \"cannot load #{obj}(#{obj.class})\"\n end\n end\n ensure\n stack.delete(object)\n end\n end\n Marshal.dump(object)\n end",
"def copy object\n\tMarshal.load(Marshal.dump(object))\nend",
"def dump\n puts \"Memory dump:\"\n @content.each_index do |index|\n puts \"%0.5d: %0.4o\" % [index, @content[index]] unless @content[index].nil?\n end\n end",
"def walk_object(object_string, this_object)\n begin\n #\n # Make sure that we don't exceed our maximum recursion level\n #\n $recursion_level += 1\n if $recursion_level > $max_recursion_level\n print_line($recursion_level, \"*** exceeded maximum recursion level ***\")\n $recursion_level -= 1\n return\n end\n #\n # Make sure we haven't dumped this object already (some data structure links are cyclical)\n #\n this_object_id = this_object.id.to_s rescue this_object.object_id.to_s\n print_line($recursion_level,\n \"Debug: this_object.method_missing(:class) = #{this_object.method_missing(:class)}\") if $debug\n this_object_class = \"#{this_object.method_missing(:class)}\".demodulize\n print_line($recursion_level, \"Debug: this_object_class = #{this_object_class}\") if $debug\n if $object_recorder.key?(this_object_class)\n if $object_recorder[this_object_class].include?(this_object_id)\n print_line($recursion_level,\n \"Object #{this_object_class} with ID #{this_object_id} has already been printed...\")\n $recursion_level -= 1\n return\n else\n $object_recorder[this_object_class] << this_object_id\n end\n else\n $object_recorder[this_object_class] = []\n $object_recorder[this_object_class] << this_object_id\n end\n #\n # Dump out the things of interest\n #\n print_attributes(object_string, this_object)\n print_virtual_columns(object_string, this_object, this_object_class)\n print_associations(object_string, this_object, this_object_class)\n print_methods(object_string, this_object) if $print_methods\n print_tags(this_object, this_object_class) if $service_model_base_supports_taggable\n print_custom_attributes(object_string, this_object)\n \n $recursion_level -= 1\n rescue => err\n $evm.log(\"error\", \"#{$method} (walk_object) - [#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n $recursion_level -= 1\n end\nend",
"def is_binary(content_type)\n if content_type.nil?\n false\n else\n content_type = content_type.downcase\n !(content_type.start_with?(\"text/\") || content_type.include?(\"json\") || content_type.include?(\"xml\"))\n end\n end",
"def dump(object)\n JsonDocument.new(@config, object).encrypt\n end",
"def recover_object\n # Up to the tab is the amount of bytes to read\n demarshal_bytes = @io.gets(\"\\t\").to_i\n \n # When at end of IO return nil\n raise NothingToRecover if demarshal_bytes.zero?\n \n blob = @io.read(demarshal_bytes)\n demarshal_object(blob)\n end",
"def dump\n Ox.dump(send mechanism)\n end",
"def store_obj_image(obj_id) #:nodoc:\n record = 0x005D # Record identifier\n length = 0x0026 # Bytes to follow\n\n obj_type = 0x0008 # Object type (Picture).\n data = '' # Record data.\n\n sub_record = 0x0000 # Sub-record identifier.\n sub_length = 0x0000 # Length of sub-record.\n sub_data = '' # Data of sub-record.\n options = 0x6011\n reserved = 0x0000\n\n # Add ftCmo (common object data) subobject\n sub_record = 0x0015 # ftCmo\n sub_length = 0x0012\n sub_data = [obj_type, obj_id, options, reserved, reserved, reserved].pack('vvvVVV')\n data = [sub_record, sub_length].pack('vv') + sub_data\n\n # Add ftCf (Clipboard format) subobject\n sub_record = 0x0007 # ftCf\n sub_length = 0x0002\n sub_data = [0xFFFF].pack( 'v')\n data = data + [sub_record, sub_length].pack('vv') + sub_data\n\n # Add ftPioGrbit (Picture option flags) subobject\n sub_record = 0x0008 # ftPioGrbit\n sub_length = 0x0002\n sub_data = [0x0001].pack('v')\n data = data + [sub_record, sub_length].pack('vv') + sub_data\n\n # Add ftEnd (end of object) subobject\n sub_record = 0x0000 # ftNts\n sub_length = 0x0000\n data = data + [sub_record, sub_length].pack('vv')\n\n # Pack the record.\n header = [record, length].pack('vv')\n\n append(header, data)\n\n end",
"def _dump(arg0)\n end",
"def test_packing_varbinary\n assert_equal \"Test string\".b, RubyVolt::DataType::Varbinary.testpacking(\"Test string\")\n assert_equal \"\".b, RubyVolt::DataType::Varbinary.testpacking(\"\")\n assert_nil RubyVolt::DataType::Varbinary.testpacking(nil)\n end",
"def serialize(_object, data)\n IO.popen(@cmd, 'w') {|io| io.write(data) }\n end",
"def should_convert?\n !dumped_ids.include?(abstract_object.object_id)\n end",
"def test_load\n content = Agoo::GraphQL.sdl_dump(with_descriptions: false, all: false)\n content.force_encoding('UTF-8')\n assert_equal(SCHEMA_EXPECT, content)\n end",
"def serialize(data)\n File.open(\"test/basic_complex_test/ruby_test/bin.babel.rb\", \"w+b\") do |f|\n f.write(data)\n end\n end",
"def dump\n do_dump(0)\n end",
"def dump\n Ox.dump(send mechanism)\n end",
"def test_has_content_eh\n a_node = Tree::TreeNode.new(\"A Node\")\n assert_nil(a_node.content , \"The node should not have content\")\n assert(!a_node.has_content? , \"The node should not have content\")\n\n a_node.content = \"Something\"\n assert_not_nil(a_node.content, \"The node should now have content\")\n assert(a_node.has_content?, \"The node should now have content\")\n end",
"def load_object(robject, data)\n robject.raw_data = data[:value]\n robject.content_type = data[:content_type]\n robject.links = data[:links]\n robject.indexes = data[:indexes]\n robject.meta = data[:meta]\n robject.etag = data[:etag]\n robject.last_modified = data[:last_modified]\n robject.vclock = data[:vclock]\n robject\n end",
"def p object\n TetCore.break_after_print\n TetCore.real_p(object)\nend",
"def dump_file_data(io)\n end",
"def build_object(type, content)\n # taken from http://schacon.github.io/gitbook/7_how_git_stores_objects.html\n header = \"#{type} #{content.size}\\0\"\n store = header + content\n [Digest::SHA1.hexdigest(store), Zlib::Deflate.deflate(store)]\n end",
"def dump_object(p_data,p_sock)\n object_dump = Marshal.dump(p_data)\n dump_length = object_dump.length.to_s\n length_str = dump_length.rjust(9,'0')\n final_data = length_str + object_dump\n outbound_data << final_data\n begin \n write_and_schedule(p_sock) \n rescue DisconnectError => sock\n close_connection(sock)\n end\n end",
"def _pack_object( obj ) \n klass = obj.class\n if klass == String\n obj\n elsif obj.respond_to?(:to_aqua) # Types requiring initialization\n obj.to_aqua( self )\n elsif obj.aquatic? && obj != self\n if obj._embed_me == true\n obj._pack\n else\n _build_stub( obj ) \n end \n else # other object without initializations\n _pack_vanilla( obj )\n end \n end",
"def test_json_object_child\n obj = { 'child' => Jeez.new(true, 58) }\n assert_equal('{\"child\":{\"json_class\":\"CompatJuice::Jeez\",\"x\":true,\"y\":58}}', Oj.dump(obj))\n end",
"def dumper(object)\n dumper_class.new(self, object)\n end",
"def find_bin obj\n find_bin_by_key(key_for_string(obj.to_s))\n end",
"def dump(*args)\n argv = to_pointer([\"dump\"] + args)\n rrd_dump(args.size+1, argv) == 0\n ensure\n free_pointers\n end",
"def incremental_dump?(object)\n\t object.respond_to?(:remote_siblings) && object.remote_siblings[self] \n\tend",
"def safe_dump_recurse(object, limit = @limit, objects = default_objects)\n\t\t\t\tif limit <= 0 || objects[object]\n\t\t\t\t\treturn replacement_for(object)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tcase object\n\t\t\t\twhen Hash\n\t\t\t\t\tobjects[object] = true\n\t\t\t\t\t\n\t\t\t\t\tobject.to_h do |key, value|\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tString(key).encode(@encoding, invalid: :replace, undef: :replace),\n\t\t\t\t\t\t\tsafe_dump_recurse(value, limit - 1, objects)\n\t\t\t\t\t\t]\n\t\t\t\t\tend\n\t\t\t\twhen Array\n\t\t\t\t\tobjects[object] = true\n\t\t\t\t\t\n\t\t\t\t\tobject.map do |value|\n\t\t\t\t\t\tsafe_dump_recurse(value, limit - 1, objects)\n\t\t\t\t\tend\n\t\t\t\twhen String\n\t\t\t\t\tobject.encode(@encoding, invalid: :replace, undef: :replace)\n\t\t\t\twhen Numeric, TrueClass, FalseClass, NilClass\n\t\t\t\t\tobject\n\t\t\t\telse\n\t\t\t\t\tobjects[object] = true\n\t\t\t\t\t\n\t\t\t\t\t# We could do something like this but the chance `as_json` will blow up.\n\t\t\t\t\t# We'd need to be extremely careful about it.\n\t\t\t\t\t# if object.respond_to?(:as_json)\n\t\t\t\t\t# \tsafe_dump_recurse(object.as_json, limit - 1, objects)\n\t\t\t\t\t# else\n\t\t\t\t\t\n\t\t\t\t\tsafe_dump_recurse(object.to_s, limit - 1, objects)\n\t\t\t\tend\n\t\t\tend",
"def load_and_report(obj) # prints a message it's adding a suitcase to the cargo hold, and gives us the suitcase's Object Id number.\n print \"Loading object \"\n puts obj.object_id # also does some reporting of the current state of the stack.\n\n add_to_stack(obj) # adding items to the instance (the stacklike thing-the cargo hold in this case)\n end",
"def string_stream\n s = @object.to_s\n s = s.dup if s.frozen?\n marker_string(0x80, 0xD0, @object.to_s.bytesize) + s.force_encoding(Encoding::BINARY)\n end",
"def inspect\n \"#{ self.class }:0x#{ '%x' % (object_id << 1) }: #{ data }\"\n end",
"def ru_debug(object)\n begin\n \"<pre class='debug_dump'>#{object.to_yaml}</pre> <p><em>Raw dump</em></p>\".html_safe\n rescue Exception => e # errors from Marshal or YAML\n # Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback\n \"<code class='debug_dump'>#{object.inspect}</code>\".html_safe\n end\n end",
"def setup_expected(blob)\n blob_content = blob.is_a?(Dataservice::Blob) ? \"/dataservice/blobs/#{blob.id}.blob/#{blob.token}\" : blob\n @expected_body = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <otrunk id=\"04dc61c3-6ff0-11df-a23f-6dcecc6a5613\">\n <imports>\n <import class=\"org.concord.otrunk.OTStateRoot\" />\n <import class=\"org.concord.otrunk.user.OTUserObject\" />\n <import class=\"org.concord.otrunk.user.OTReferenceMap\" />\n <import class=\"org.concord.otrunk.ui.OTCardContainer\" />\n <import class=\"org.concord.otrunk.ui.OTSection\" />\n <import class=\"org.concord.otrunk.ui.OTChoice\" />\n <import class=\"org.concord.otrunk.ui.OTText\" />\n <import class=\"org.concord.datagraph.state.OTDataGraphable\" />\n <import class=\"org.concord.data.state.OTDataStore\" />\n <import class=\"org.concord.otrunk.util.OTLabbookBundle\" />\n <import class=\"org.concord.otrunk.util.OTLabbookEntry\" />\n <import class=\"org.concord.datagraph.state.OTDataCollector\" />\n <import class=\"org.concord.datagraph.state.OTDataAxis\" />\n <import class=\"org.concord.otrunk.view.OTFolderObject\" />\n <import class=\"org.concord.framework.otrunk.wrapper.OTBlob\" />\n <import class=\"org.concord.graph.util.state.OTDrawingTool\" />\n <import class=\"org.concord.otrunk.labbook.OTLabbookButton\" />\n <import class=\"org.concord.otrunk.labbook.OTLabbookEntryChooser\" />\n </imports>\n <objects>\n <OTReferenceMap>\n <user>\n <OTUserObject id=\"c2f96d5e-6fee-11df-a23f-6dcecc6a5613\" />\n </user>\n <map>\n <entry key=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!/lab_book_bundle\">\n <OTLabbookBundle>\n <entries>\n <OTLabbookEntry timeStamp=\"June 4 at 11:39\" type=\"Graphs\" note=\"Add a note describing this entry...\">\n <oTObject>\n <OTDataCollector id=\"540d78fe-6fef-11df-a23f-6dcecc6a5613\" useDefaultToolBar=\"false\" showControlBar=\"true\" title=\"Government Support for Educational Technology\" displayButtons=\"4\" name=\"Government Support for Educational Technology\" multipleGraphableEnabled=\"false\" autoScaleEnabled=\"false\">\n <source>\n <OTDataGraphable drawMarks=\"true\" connectPoints=\"true\" visible=\"true\" color=\"16711680\" showAllChannels=\"false\" name=\"Governmen...\" xColumn=\"0\" lineWidth=\"2.0\" yColumn=\"1\" controllable=\"false\">\n <dataStore>\n <OTDataStore numberChannels=\"2\" />\n </dataStore>\n </OTDataGraphable>\n </source>\n <xDataAxis>\n <OTDataAxis min=\"1981.708\" max=\"2020.0248\" label=\"Time\" labelFormat=\"None\" units=\"years\">\n <customGridLabels />\n </OTDataAxis>\n </xDataAxis>\n <dataSetFolder>\n <OTFolderObject />\n </dataSetFolder>\n <yDataAxis>\n <OTDataAxis min=\"19.401735\" max=\"82.00013\" label=\"Temperature\" labelFormat=\"None\" units=\"C\">\n <customGridLabels />\n </OTDataAxis>\n </yDataAxis>\n </OTDataCollector>\n </oTObject>\n <container>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!/section_card_container_activity_17/cards[0]\" />\n </container>\n <originalObject>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!/data_collector_3\" />\n </originalObject>\n </OTLabbookEntry>\n <OTLabbookEntry timeStamp=\"June 4 at 11:41\" type=\"Snapshots\" note=\"Add a note describing this entry...\">\n <oTObject>\n <OTBlob id=\"aae0cc59-6fef-11df-a23f-6dcecc6a5613\">\n <src>' + blob_content + '</src>\n </OTBlob>\n </oTObject>\n <container>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!/section_card_container_activity_17/cards[0]\" />\n </container>\n <originalObject>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!/mw_modeler_page_2\" />\n </originalObject>\n <drawingTool>\n <OTDrawingTool id=\"aae0cc5b-6fef-11df-a23f-6dcecc6a5613\" scaleBackground=\"true\">\n <backgroundSrc>\n <object refid=\"aae0cc59-6fef-11df-a23f-6dcecc6a5613\" />\n </backgroundSrc>\n </OTDrawingTool>\n </drawingTool>\n </OTLabbookEntry>\n </entries>\n </OTLabbookBundle>\n </entry>\n <entry key=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!/nested_objects_with_ids\">\n <OTBasicObject>\n <child>\n <OTBasicObject name=\"First\" id=\"onetwothree\">\n <child>\n <OTBasicObject name=\"Second\" id=\"fourfivesix\" />\n </child>\n </OTBasicObject>\n </child>\n </OTBasicObject>\n </entry>\n </map>\n </OTReferenceMap>\n </objects>\n </otrunk>\n\n '\n\n @reconstituted_regex = /<\\?xml version=\"1\\.0\" encoding=\"UTF-8\"\\?>\n<otrunk id=\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\">\n <imports>\n <import class=\"org.concord.otrunk.OTStateRoot\" \\/>\n <import class=\"org.concord.otrunk.user.OTUserObject\" \\/>\n <import class=\"org.concord.otrunk.user.OTReferenceMap\" \\/>\n <import class=\"org.concord.otrunk.ui.OTCardContainer\" \\/>\n <import class=\"org.concord.otrunk.ui.OTSection\" \\/>\n <import class=\"org.concord.otrunk.ui.OTChoice\" \\/>\n <import class=\"org.concord.otrunk.ui.OTText\" \\/>\n <import class=\"org.concord.datagraph.state.OTDataGraphable\" \\/>\n <import class=\"org.concord.data.state.OTDataStore\" \\/>\n <import class=\"org.concord.otrunk.util.OTLabbookBundle\" \\/>\n <import class=\"org.concord.otrunk.util.OTLabbookEntry\" \\/>\n <import class=\"org.concord.datagraph.state.OTDataCollector\" \\/>\n <import class=\"org.concord.datagraph.state.OTDataAxis\" \\/>\n <import class=\"org.concord.otrunk.view.OTFolderObject\" \\/>\n <import class=\"org.concord.framework.otrunk.wrapper.OTBlob\" \\/>\n <import class=\"org.concord.graph.util.state.OTDrawingTool\" \\/>\n <import class=\"org.concord.otrunk.labbook.OTLabbookButton\" \\/>\n <import class=\"org.concord.otrunk.labbook.OTLabbookEntryChooser\" \\/>\n <\\/imports>\n <objects>\n <OTStateRoot formatVersionString=\"1.0\">\n <userMap>\n <entry key=\"somefakeid\">\n <OTReferenceMap>\n <user>\n <OTUserObject id=\"somefakeid\" \\/>\n <\\/user>\n <map>\n <entry key=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!\\/lab_book_bundle\">\n <OTLabbookBundle>\n <entries>\n <OTLabbookEntry timeStamp=\"June 4 at 11:39\" type=\"Graphs\" note=\"Add a note describing this entry...\">\n <oTObject>\n <object refid=\"540d78fe-6fef-11df-a23f-6dcecc6a5613\"\\/>\n <\\/oTObject>\n <container>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!\\/section_card_container_activity_17\\/cards[0]\" \\/>\n <\\/container>\n <originalObject>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!\\/data_collector_3\" \\/>\n <\\/originalObject>\n <\\/OTLabbookEntry>\n <OTLabbookEntry timeStamp=\"June 4 at 11:41\" type=\"Snapshots\" note=\"Add a note describing this entry...\">\n <oTObject>\n <object refid=\"aae0cc59-6fef-11df-a23f-6dcecc6a5613\"\\/>\n <\\/oTObject>\n <container>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!\\/section_card_container_activity_17\\/cards[0]\" \\/>\n <\\/container>\n <originalObject>\n <object refid=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!\\/mw_modeler_page_2\" \\/>\n <\\/originalObject>\n <drawingTool>\n <object refid=\"aae0cc5b-6fef-11df-a23f-6dcecc6a5613\"\\/>\n <\\/drawingTool>\n <\\/OTLabbookEntry>\n <\\/entries>\n <\\/OTLabbookBundle>\n <\\/entry>\n <entry key=\"fe6dcc58-6f7d-11df-81fc-001ec94098a1!\\/nested_objects_with_ids\">\n <OTBasicObject>\n <child>\n <object refid=\"onetwothree\"\\/>\n <\\/child>\n <\\/OTBasicObject>\n <\\/entry>\n <\\/map>\n <annotations>\n <entry key=\"540d78fe-6fef-11df-a23f-6dcecc6a5613\">\n <OTDataCollector id=\"540d78fe-6fef-11df-a23f-6dcecc6a5613\" useDefaultToolBar=\"false\" showControlBar=\"true\" title=\"Government Support for Educational Technology\" displayButtons=\"4\" name=\"Government Support for Educational Technology\" multipleGraphableEnabled=\"false\" autoScaleEnabled=\"false\">\n <source>\n <OTDataGraphable drawMarks=\"true\" connectPoints=\"true\" visible=\"true\" color=\"16711680\" showAllChannels=\"false\" name=\"Governmen...\" xColumn=\"0\" lineWidth=\"2.0\" yColumn=\"1\" controllable=\"false\">\n <dataStore>\n <OTDataStore numberChannels=\"2\" \\/>\n <\\/dataStore>\n <\\/OTDataGraphable>\n <\\/source>\n <xDataAxis>\n <OTDataAxis min=\"1981.708\" max=\"2020.0248\" label=\"Time\" labelFormat=\"None\" units=\"years\">\n <customGridLabels \\/>\n <\\/OTDataAxis>\n <\\/xDataAxis>\n <dataSetFolder>\n <OTFolderObject \\/>\n <\\/dataSetFolder>\n <yDataAxis>\n <OTDataAxis min=\"19.401735\" max=\"82.00013\" label=\"Temperature\" labelFormat=\"None\" units=\"C\">\n <customGridLabels \\/>\n <\\/OTDataAxis>\n <\\/yDataAxis>\n <\\/OTDataCollector>\n <\\/entry>\n <entry key=\"aae0cc59-6fef-11df-a23f-6dcecc6a5613\">\n <OTBlob id=\"aae0cc59-6fef-11df-a23f-6dcecc6a5613\">\n <src>http:.*<\\/src>\n <\\/OTBlob>\n <\\/entry>\n <entry key=\"aae0cc5b-6fef-11df-a23f-6dcecc6a5613\">\n <OTDrawingTool id=\"aae0cc5b-6fef-11df-a23f-6dcecc6a5613\" scaleBackground=\"true\">\n <backgroundSrc>\n <object refid=\"aae0cc59-6fef-11df-a23f-6dcecc6a5613\" \\/>\n <\\/backgroundSrc>\n <\\/OTDrawingTool>\n <\\/entry>\n <entry key=\"fourfivesix\">\n <OTBasicObject name=\"Second\" id=\"fourfivesix\" \\/>\n <\\/entry>\n <entry key=\"onetwothree\">\n <OTBasicObject name=\"First\" id=\"onetwothree\">\n <child>\n <object refid=\"fourfivesix\"\\/>\n <\\/child>\n <\\/OTBasicObject>\n <\\/entry>\n <\\/annotations>\n <\\/OTReferenceMap>\n <\\/entry>\n <\\/userMap>\n <\\/OTStateRoot>\n <\\/objects>\n<\\/otrunk>/m\n end",
"def dprint(obj)\n self.log_puts(Php4r.print_r(obj, true))\n end",
"def dump(obj, error = false)\n #\n # Place a temp hold on the object until the client registers it.\n #\n obj.holdBrokerObj if obj.respond_to?(:holdBrokerObj)\n\n return(dump_original(obj, error)) unless obj.kind_of?(MiqDrbReturn)\n begin\n return(dump_original(obj.obj, error))\n ensure\n if obj.lock && obj.lock.sync_locked?\n $vim_log.debug \"DRb::DRbMessage.dump: UNLOCKING [#{Thread.current.object_id}] <#{obj.obj.object_id}>\" if $vim_log.debug?\n obj.lock.sync_unlock\n end\n end\n end"
] |
[
"0.6263297",
"0.61053145",
"0.6102183",
"0.6070473",
"0.6068636",
"0.606498",
"0.6060673",
"0.603301",
"0.60080266",
"0.5982621",
"0.5982621",
"0.59586066",
"0.5907594",
"0.58899474",
"0.58816576",
"0.5851618",
"0.58489805",
"0.58051205",
"0.5704244",
"0.57041013",
"0.56952083",
"0.5691871",
"0.56817025",
"0.5660948",
"0.5654076",
"0.56259245",
"0.56011635",
"0.557055",
"0.5569227",
"0.55370647",
"0.55327636",
"0.5528215",
"0.5466939",
"0.54598",
"0.54373974",
"0.5433116",
"0.5432364",
"0.5423491",
"0.54229647",
"0.5422706",
"0.5408187",
"0.5402247",
"0.54016465",
"0.54016465",
"0.53796166",
"0.5369777",
"0.5347177",
"0.53431445",
"0.5341344",
"0.53384185",
"0.53348494",
"0.5334098",
"0.5333212",
"0.532735",
"0.5322107",
"0.5319173",
"0.531171",
"0.53091943",
"0.52867866",
"0.5285318",
"0.5283212",
"0.5261411",
"0.52231985",
"0.52205414",
"0.5217295",
"0.52083045",
"0.5205859",
"0.51997185",
"0.5191749",
"0.5187793",
"0.51636285",
"0.51556075",
"0.51472306",
"0.5146327",
"0.5136814",
"0.51353794",
"0.51323193",
"0.5129636",
"0.512889",
"0.5118646",
"0.5109162",
"0.5107178",
"0.50943756",
"0.5086961",
"0.5082674",
"0.5074634",
"0.5070064",
"0.50641775",
"0.50428224",
"0.5023349",
"0.5011425",
"0.5004737",
"0.5004526",
"0.50033396",
"0.49986383",
"0.49941775",
"0.4989834",
"0.49884513",
"0.49874863",
"0.49835345"
] |
0.6296182
|
0
|
Test the collect method from the mixedin Enumerable functionality.
|
def test_collect
setup_test_tree
collect_array = @root.collect do |node|
node.content = "abc"
node
end
collect_array.each {|node| assert_equal("abc", node.content, "Should be 'abc'")}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_collect_transforms_elements_of_an_array\n array = [1, 2, 3]\n new_array = array.collect { |item| item + 10 }\n assert_equal [11, 12, 13], new_array\n\n # NOTE: 'map' is another name for the 'collect' operation\n another_array = array.map { |item| item + 10 }\n assert_equal [11, 12, 13], another_array\n end",
"def test_collect_transforms_elements_of_an_array\n array = [1, 2, 3]\n new_array = array.collect { |item| item + 10 }\n assert_equal [11, 12, 13], new_array\n\n another_array = array.map { |item| item + 10 }\n assert_equal [11, 12, 13], another_array\n end",
"def collect; end",
"def test_0120_collect\n @@log.debug \"test_0120_collect starts\" if @@log.debug?\n assert_respond_to(@list, :collect, \"test_0120_collect_respond\")\n # And array of dummy objects is returned\n new_list = @list.collect { \"dummy\" }\n assert(new_list.size == @list.size,\"test_0120_collect_basic\")\n assert(new_list[@list.size - 1] == \"dummy\",\"test_0120_collect_sizecheck\")\n # Check Enumerator or Array return, no block given\n new_list = @list.collect\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0120_collect_enumcheck\")\nelse\n result = new_list.is_a? Array\n assert(result, \"test_0120_collect_arraycheck\")\nend\n # Create new Array 2\n new_list = @list.collect {|obj| obj.ndata * 2 }\n assert(new_list == [8,6,4,2], \"test_0120_collect_ndx2\")\n # Create new Array 3\n new_list = @list.collect {|obj| obj.last }\n expected = [\"Newman\", \"Barker\", \"Bronson\", \"Dev\"]\n assert(new_list == expected, \"test_0120_collect_lastname\")\n @@log.debug \"test_0120_collect ends\" if @@log.debug?\n end",
"def test_collect_array_no_block\n assert_nothing_raised{ @words.collect }\n assert_equal(%w/foo bar baz/, @words.collect)\n assert_equal(%w/FOO BAR BAZ/, @words.collect(:upcase))\n assert_equal(%w/fooA barA bazA/, @words.collect(:+, 'A'))\n assert_equal(%w/foo bar baz/, @words) # Verify receiver unmodified\n end",
"def collect\n end",
"def test_collects_no_modifications\n seed = [1, 2, 3]\n stream = FromArray.new(seed)\n assert(\n seed == stream.collect,\n 'The seed and collected array should be the equal!'\n )\n assert(\n !seed.equal?(stream.collect),\n 'The seed and collected array should not be the same!'\n )\n end",
"def collect!\n block_given? or return enum_for(__method__) { size }\n set = self.class.new\n each { |o| set << yield(o) }\n replace(set)\n end",
"def test_try_each_instead_of_collect_change_array\n array = [1, 2, 3]\n array = array.each { |item| item + 10 }\n #assert_equal [11, 12, 13], array\n assert_equal [1, 2, 3], array\n end",
"def collect(*args, &block)\n all.collect(*args, &block)\n end",
"def collect!\n block_given? or return enum_for(__method__)\n set = self.class.new\n each { |o| set << yield(o) }\n replace(set)\n end",
"def collect!(&block)\n unless block_given?\n return ArrayEnumerator.new(self, :collect! ) # for 1.8.7\n end\n i = 0\n sz = self.__size\n enum_res = self.each { | elem | # use self.each to handle break in block\n self.__at_put(i, block.call( elem ) )\n i += 1\n }\n if i < sz\n return enum_res\n end\n self\n end",
"def my_collect(array)\n i = 0\n collection = []\n while i < array.size\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def collect!\n els = @elements.collect! {|v| yield(v)}\n Vector.elements(els, false)\n end",
"def my_collect(array)\n collection = []\n index = 0\n while index < array.size\n collection << yield(array[index])\n index += 1\n end\n collection\nend",
"def test_0910_collect_concat\n @@log.debug \"test_0910_collect_concat starts\" if @@log.debug?\n assert_respond_to(@list, :collect_concat, \"test_0910_collect_concat_respond\")\n # Need some arrays for this test .....\n part_one = [@aen, @bsb]\n part_two = [@cab, @dad]\n ary_all = [ part_one, part_two ]\n # This should be the orignal list\n cc_res = ary_all.collect_concat {|pers| pers }\n 0.upto(cc_res.size-1) do |n|\n # Each element should be the same\n assert(cc_res[n] == @list[n], \"test_0910_collect_concat_eltck_#{n}\")\n end\n #\n assert(cc_res == @list.to_a, \"test_0910_collect_concat_eltck_all\")\n #\n @@log.debug \"test_0910_collect_concat ends\" if @@log.debug?\n end",
"def my_collect(array)\n if block_given?\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i+=1\n end\n else\n puts \"Hey! No block given!\"\n end #block_given?\n collection\nend",
"def collect\n nha = self.class.new\n (0...self.length).each { |i| nha << yield(self.fetch(i)) }\n nha\n end",
"def collect(&block)\n return to_enum :collect unless block\n\n ary = []\n self.each{|*val| ary.push(block.call(*val))}\n ary\n end",
"def test_filters_no_elements\n stream = FromArray.new([2, 4, 6, 8])\n collected = stream.filter { |num| num % 2 == 0 }.collect\n assert(stream.collect == collected)\n end",
"def my_collect(array) # put argument(s) here\n # code here\n i = 0\n result = []\n\n while i < array.size\n\n result << yield(array[i])\n i += 1\n end\nresult\nend",
"def my_collect(array)\n \n i = 0 \n collect = []\n \n while i < array.length \n collect << yield(array[i])\n i += 1\n end\n \n collect \nend",
"def each(&block)\n @collection.each do |collectable|\n if block_given?\n block.call collectable\n else \n yield collectable\n end\n end \n end",
"def my_collect(array)\n i = 0\n collect = []\n while i < array.length\n collect << yield(array[i])\n i += 1\n end\n collect\nend",
"def my_collect(array)\n i = 0\n collect = []\n while i < array.length\n collect << yield(array[i])\n i+=1\n end\n collect\nend",
"def map\n reset_iteration\n return enum_for(:collect) unless block_given?\n [].tap { |ret| loop { ret << yield(self.next) } }\n end",
"def thread_collect\n collection = Array.new\n thread_each do |e|\n collection << yield(e)\n end\n collection\n end",
"def my_collect(array)\ni = 0\n\nnewArray = []\nwhile i < array.length\n\n newArray.push(yield array[i])\n i = i + 1\nend\nnewArray\nend",
"def map(collection)\n result = []\n collection.each { |el| result << yield(el)}\n result\nend",
"def collect! &block\n collect(&block)\n ok!\n @messages\n end",
"def\tcollect\n\t\ta = []\n\t\tself.each{|v| a << v}\n\t\ta\n\tend",
"def test_skips_all_elements\n stream = FromArray.new([1, 2, 3])\n collected = stream.skip(3).collect\n assert(\n collected == [],\n 'Expected ' + [].to_s + ' but got ' + collected.to_s\n )\n end",
"def my_collect(array)\n i = 0\n name_collection = []\n while i < array.length\n name_collection.push yield(array[i])\n # you could also do it this way:\n # name_collection << yield(array[i])\n i += 1\n end\n name_collection\nend",
"def my_collect(array, &block)\nnew_array = []\ncounter =0\nif block_given?\nwhile counter < array.length\n new_array[counter] = yield(array[counter])\n counter +=1\nend\nreturn new_array\nelse \n return self.to_enum\nend\nend",
"def test_filter_elements\n stream = FromArray.new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n collected = stream.filter { |num| num % 2 == 0 }.collect\n collected.each do |val|\n assert(val.even?)\n end\n end",
"def test_flatten\n with_a_collection do\n assert_equal 10, @coll.flatten!.size\n assert_instance_of QualityCenter::Defect::Item, @coll.last\n end\n end",
"def some_method (testing1)\n\tputs testing1.collect! {|num| num**3} # method 2\nend",
"def each(&a_proc); end",
"def test_all_iteration_methods_work_on_any_collection_not_just_arrays\n # Ranges act like a collection\n result = (1..3).map { |item| item + 10 }\n assert_equal [11, 12, 13], result\n\n # Files act like a collection of lines. Mix-ins? Or does it just quack like\n # a collection-duck?\n File.open(\"example_file.txt\") do |file|\n upcase_lines = file.map { |line| line.strip.upcase }\n assert_equal ['THIS', 'IS', 'A', 'TEST'], upcase_lines\n end\n\n # NOTE: You can create your own collections that work with each,\n # map, select, etc.\n end",
"def square_array_with_collect(array)\n array.collect{|element| element**2}\nend",
"def my_collect(array)\n new_array = []\n # if array.size == 0\n # return 0\n # else\n counter = 0\n while counter < array.length\n new_array << yield(array[counter])\n counter += 1\n end\n \n new_array\nend",
"def _collect(collection_item, api_method)\n results = []\n\n response(api_method).each_page do |page|\n results += page.collect(&collection_item)\n end\n\n results\n end",
"def test_skips_all_elements_count_gt_size\n stream = FromArray.new([1, 2, 3])\n collected = stream.skip(4).collect\n assert(\n collected == [],\n 'Expected ' + [].to_s + ' but got ' + collected.to_s\n )\n end",
"def test_maps_no_elements\n stream = FromArray.new([])\n collected = stream.map { |val| val.to_s }.collect\n assert(collected.empty?)\n end",
"def test_empty_distinct\n stream = FromArray.new([])\n collected = stream.distinct.collect\n assert(collected.length.zero?)\n end",
"def square_collect(array)\n\n return array.collect do |x|\n x ** 2\n end\n\nend",
"def collect\n [false, nil]\n end",
"def my_select (collection)\n if block_given?\n i = 0 \n new_collection = []\n \n while i < collection.length \n if yield(collection[i]) \n new_collection << collection[i]\n end\n i += 1\n end\n \n else\n puts \"Hey! No block was given!\"\n end\n new_collection \nend",
"def my_collect(input_array)\n if block_given?\n counter = 0\n output = []\n while counter < input_array.size\n output << yield(input_array[counter])\n counter +=1\n end\n output\n end\n\n\n\n\nend",
"def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end",
"def my_select(coll)\n # your code here!\n mod_coll = []\n i=0\n while i < coll.length\n if (yield(coll[i]))\n mod_coll.push(coll[i])\n end\n i = i+1\n end\n mod_coll\nend",
"def collect(result_array)\n collection = result_array.collect { |item| new(item)}\n result_array.replace(collection)\n result_array\n end",
"def test_map_elements\n stream = FromArray.new([1, 2, 3])\n strings = stream.map { |num| num.to_s }.collect\n strings.each do |val|\n assert(val.is_a?(String))\n end\n end",
"def test_skip_more_elements\n stream = FromArray.new([1, 2, 3])\n collected = stream.skip(2).collect\n assert(\n collected == [3],\n 'Expected ' + [3].to_s + ' but got ' + collected.to_s\n )\n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def test_3\n f = Foo.new\n z = f.iterate_collection(\"device_worker\")\n assert_equal LOAD, z\n end",
"def test_5\n f = Foo.new\n z = f.iterate_collection(\"device_worker\")\n assert_equal LOAD, z\n end",
"def test_distinct_no_duplicates\n stream = FromArray.new([1, 2, 3, 4, 5])\n collected = stream.distinct.collect\n assert(collected == collected.uniq)\n assert(collected.length == collected.uniq.length)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item|\n if item.is_a? Integer\n item += thing_to_modify\n else item\n end\n end\n return source\nend",
"def collect\n raise Errors::ActionMethodNotImplemented.new 'Collect actions must overwrite the collect method.'\n end",
"def my_collect(words_array)\n counter = 0\n new_array = [] # this is the array we will push it into\n # grab (iterate through) each item in that array\n while counter < words_array.length\n# push the result of that action into a new array\n new_array << yield(words_array[counter])\n counter += 1\n end\n new_array\nend",
"def each(&block)\n to_set.each(&block)\n end",
"def coerce(value)\n coerced = super\n return coerced unless coerced.respond_to?(:each_with_object)\n coerced.each_with_object(new_collection) do |entry, collection|\n coerce_and_append_member(collection, entry)\n end\n end",
"def test_0275_select\n @@log.debug \"test_0275_select starts\" if @@log.debug?\n assert_respond_to(@list, :select, \"test_0275_select_respond\")\n # Basic select check\n ta = @list.select {|obj| obj.first <= \"Bob\" }\n assert_equal([@aen, @bsb], ta, \"test_0275_select_eq01\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.select\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0275_select_enumcheck\")\nelse\n # Note: the author's version of the 1.8 Pickaxe documents this\n # as an Array. Note however that this form is not documented by\n # that publication at all.\n # YMMV.\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0275_select_enumenumcheck\")\nend\n @@log.debug \"test_0275_select ends\" if @@log.debug?\n end",
"def test_each\n # codecite examples\n evens = Sequence.new(5, 2) {|a| a.last + 2} \n odds = Sequence.new(5, 1) {|a| a.last + 2}\n fibs = Sequence.new(5, 1, 1) {|a| a[-2] + a[-1]}\n # codecite examples\n \n assert_equal [2,4,6,8,10], evens.to_a\n assert_equal [1,3,5,7,9], odds.to_a\n assert_equal [1,1,2,3,5], fibs.to_a\n end",
"def square_array_collect(array)\n array.collect{|num| num ** 2}\nend",
"def my_select(collection)\n holder = [] #for collection at the end\n counter = 0 #start at beginning of array\n\n while counter < collection.length # condition to be met\n if yield(collection[counter]) == true #if the mumbojumbo results in true *which select gives\n holder.push(collection[counter]) #then push that element into the new array\n end\n counter += 1 #iterate throughout the array incremently\n end\n holder #show everyone your new array\nend",
"def each(&blk)\r\n to_a.each(&blk)\r\n end",
"def each(&block)\n to_a.each(&block)\n end",
"def each(&blk)\n to_a.each(&blk)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend",
"def test_methods_can_call_yield_many_times\n result = []\n many_yields { |item| result << item }\n assert_equal [:peanut, :butter, :and, :jelly], result\n end",
"def each_set\n \n end",
"def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def my_collect(arr)\narr2 = []\n i = 0\n while i < arr.length\n arr2 << arr[i].upcase\n yield arr[i]\n i += 1\n end\n\n arr2\nend",
"def each(&block)\n @collection.each(&block)\n end",
"def take_all; end",
"def collects(key, as:, **opts)\n type_of! key, must_be: as\n track_collection key, as, **opts\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend",
"def test_map\n array = [1,2,3,4,5,6,7,8]\n array = array.map {|x| x*2}\n assert_equal [2, 4, 6, 8, 10, 12, 14, 16] , array\n end",
"def test_0130_map\n @@log.debug \"test_0130_map starts\" if @@log.debug?\n assert_respond_to(@list, :map, \"test_0130_map_respond\")\n # And array of dummy objects is returned\n new_list = @list.map { \"dummy\" }\n assert(new_list.size == @list.size,\"test_0130_map_basic\")\n assert(new_list[@list.size - 1] == \"dummy\",\"test_0130_map_sizecheck\")\n # Check Enumerator or Array return, no block given\n new_list = @list.map\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0130_map_enumcheck\")\nelse\n result = new_list.is_a? Array\n assert(result, \"test_0130_map_arraycheck\")\nend\n # Create new Array 2\n new_list = @list.map {|obj| obj.ndata * 2 }\n assert(new_list == [8,6,4,2], \"test_0130_map_ndx2\")\n # Create new Array 3\n new_list = @list.map {|obj| obj.last }\n expected = [\"Newman\", \"Barker\", \"Bronson\", \"Dev\"]\n assert(new_list == expected, \"test_0130_map_lastname\")\n @@log.debug \"test_0130_map ends\" if @@log.debug?\n end",
"def square_array(some_array)\n some_array.collect {|num| num*num} \nend",
"def visit_collection(input, *arguments)\n collection = []\n input.each do |object|\n runner = visit(object, *arguments)\n collection << runner\n @stop = runner.stop?\n break if @stop\n end\n collection\n end",
"def test_filter_returns_new_instance\n stream = FromArray.new([2, 4, 6, 8])\n assert(!stream.filter(&:odd?).equal?(stream))\n assert(stream.collect == [2, 4, 6, 8])\n end",
"def test_array_select2\n a = [2, 5, 2, 2, 3]\n num = a.select {|n| n == 2}\n assert_equal([2, 2, 2], num)\n end",
"def consume_each(&block)\r\n @arr = @arr.reject(&block)\r\n end",
"def collect(mapping)\n Collector.new(mapping, runner).run(@changes, @history)\n end",
"def each_identity; end",
"def each(&blk); each_value(&blk) ; end",
"def test_filters_all_elements\n stream = FromArray.new([2, 4, 6, 8])\n assert(stream.filter { |num| num % 2 != 0 }.count == 0)\n end",
"def each(&block)\n internal_collection.each(&block)\n end"
] |
[
"0.7641104",
"0.7519661",
"0.7514939",
"0.74053234",
"0.7126162",
"0.7126018",
"0.7092514",
"0.6817597",
"0.66804314",
"0.66524094",
"0.6643883",
"0.656589",
"0.63235676",
"0.62671983",
"0.62116736",
"0.6147768",
"0.6137684",
"0.6104986",
"0.60806155",
"0.60591465",
"0.604867",
"0.60460514",
"0.60342395",
"0.60087955",
"0.6000675",
"0.59797776",
"0.58953637",
"0.58210486",
"0.5768014",
"0.5764144",
"0.5748458",
"0.5716648",
"0.57165766",
"0.5707583",
"0.56803983",
"0.56502515",
"0.5606502",
"0.56001884",
"0.56000435",
"0.5597631",
"0.5588796",
"0.5569194",
"0.5564855",
"0.5533549",
"0.5529926",
"0.55202836",
"0.55168444",
"0.55013883",
"0.54918367",
"0.5489296",
"0.5466062",
"0.54554176",
"0.54518664",
"0.5451845",
"0.5440841",
"0.5440841",
"0.5440841",
"0.5440841",
"0.5440841",
"0.5440841",
"0.5432496",
"0.5429788",
"0.54148716",
"0.54107636",
"0.5406696",
"0.5393983",
"0.5388955",
"0.5384658",
"0.5375345",
"0.53750694",
"0.5375058",
"0.5354159",
"0.5339733",
"0.53342587",
"0.5331051",
"0.5320502",
"0.5320502",
"0.531374",
"0.53121924",
"0.530831",
"0.530831",
"0.530831",
"0.5298932",
"0.5283231",
"0.52683866",
"0.5266813",
"0.52504516",
"0.52504516",
"0.5244446",
"0.52311504",
"0.522971",
"0.52272236",
"0.51856935",
"0.51777834",
"0.5164164",
"0.51629245",
"0.5161766",
"0.5159046",
"0.51587355",
"0.51459175"
] |
0.6561504
|
12
|
Test freezing the tree
|
def test_freeze_tree_bang
setup_test_tree
@root.content = "ABC"
assert_equal("ABC", @root.content, "Content should be 'ABC'")
@root.freeze_tree!
# Note: The error raised here depends on the Ruby version.
# For Ruby > 1.9, RuntimeError is raised
# For Ruby ~ 1.8, TypeError is raised
assert_raise(RuntimeError, TypeError) {@root.content = "123"}
assert_raise(RuntimeError, TypeError) {@root[0].content = "123"}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cheap_wait; end",
"def test_should_block_recursion_in_tree\n group = Group.find @greeks_group.id\n\n assert_raises(RecursionInTree) { group.parent = Group.find @cretes_group.id }\n end",
"def test_save_tree\n end",
"def test_cyclic\n end",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def test_GC_ClassMethods_stree=\n\t\tassert_equal(false, GC.stress)\n\tend",
"def test_breadth\n assert_equal(1, @root.breadth, \"A single node's breadth is 1\")\n\n @root << @child1\n assert_equal(1, @root.breadth, \"This should be of breadth 1\")\n\n @root << @child2\n assert_equal(2, @child1.breadth, \"This should be of breadth 2\")\n assert_equal(2, @child2.breadth, \"This should be of breadth 2\")\n\n @root << @child3\n assert_equal(3, @child1.breadth, \"This should be of breadth 3\")\n assert_equal(3, @child2.breadth, \"This should be of breadth 3\")\n\n @child3 << @child4\n assert_equal(1, @child4.breadth, \"This should be of breadth 1\")\n end",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def process_tree_with_renew\n @process_tree = nil\n process_tree\n end",
"def change_tree(*args)\n begin\n self.model.freeze_notify\n yield(self, *args)\n ensure\n self.model.thaw_notify\n end\n self\n end",
"def test_load_ignores_duplicates\n tree = BinarySearchTree.new\n tree.load\n target = tree.load\n assert_nil target\n end",
"def waiting; end",
"def waiting; end",
"def testInvalidatedAlreadyTriedPathsDueToDependencies\n # TODO: Code the already tried paths invalidated feature, and uncomment after\n# executeSimpleTest(\n# [ [ 'T1', 'R3', 10, 3, ['T2'], '==='],\n# [ 'T2', 'R4', 500, 2, [], ' =='],\n# [ 'T3', 'R1', 600, 2, ['T2'], '=='],\n# [ 'T4', 'R1', 400, 2, ['T2', 'T7'], ' =='],\n# [ 'T5', 'R2', 300, 2, ['T2', 'T7'], '=='],\n# [ 'T6', 'R2', 200, 2, ['T7'], ' =='],\n# [ 'T7', 'R5', 700, 2, [], ' =='],\n# [ 'T8', 'R6', 20, 3, ['T7'], '==='] ] )\n executeSimpleTest(\n [ [ 'T1', 'R3', 10, 3, ['T2'], '==='],\n [ 'T2', 'R4', 500, 2, [], ' =='],\n [ 'T3', 'R1', 600, 2, ['T2'], ' =='],\n [ 'T4', 'R1', 400, 2, ['T2', 'T7'], '=='],\n [ 'T5', 'R2', 300, 2, ['T2', 'T7'], '=='],\n [ 'T6', 'R2', 200, 2, ['T7'], ' =='],\n [ 'T7', 'R5', 700, 2, [], ' =='],\n [ 'T8', 'R6', 20, 3, ['T7'], '==='] ] )\n end",
"def clean_stale_lockfiles(zk, config)\n children = zk.get_children(:path => config[:root])\n children[:children].each do |child|\n # skip all the children that aren't ours\n next unless child.start_with?(config[:lockname] + \".\")\n cstat = zk.stat(:path => \"#{config[:root]}/#{child}\")\n next unless cstat[:stat].exists #someone else may have deleted it already\n puts \"testing child #{child} for deletion; it is #{Time.now() - Time.at(cstat[:stat].ctime / 1000)} seconds old\" if config[:verbose]\n # cstat gives time in ms\n if Time.at(cstat[:stat].ctime / 1000) < Time.now() - config[:locktime]\n puts \"deleting stale lockfile #{child}\" if config[:verbose]\n zk.delete(:path => \"#{config[:root]}/#{child}\")\n end\n end\nend",
"def wait; end",
"def wait; end",
"def wait; end",
"def verify\n 1.upto(@leaf_count - 1) do |node|\n next if @nodes[node] ==\n HashTree.node_hash(node, @nodes[HashTree.left_child(node)],\n @nodes[HashTree.right_child(node)])\n raise \"Tree integrity verification failed\" \n end\n self\n end",
"def valid_tree?\n false\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def test_remove_all_bang\n setup_test_tree\n assert(@root.has_children?, \"Should have children\")\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_waiting_list_order\n # @todo don't know yet how to list waiting list\n # @todo original plan was just to have a waitinglist queue and only next is available to view\n puts \"Test under construction: waiting_list_order\"\n end",
"def test_tree_starts_empty\n tree = BinarySearchTree.new\n assert_nil tree.root\n end",
"def test_for_node\n raise \"Failing test #{@name} for #{@node}\" if Node.fail_for.key?(@name) && Node.fail_for[@name].include?(@node)\n\n sleep_time = Node.sleeps.dig(@name, @node)\n sleep sleep_time unless sleep_time.nil?\n Node.runs << [@name, @node]\n end",
"def test_return_method_falsey\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal true, @tree.includes?(\"c\")\n end",
"def freeze() end",
"def freeze() end",
"def test_delve\n top = mk_transtree do |object, depth, width|\n object.file = :funtest if width % 2 == 1\n end\n\n objects = []\n buckets = []\n found = []\n\n count = 0\n assert_nothing_raised {\n top.delve do |object|\n count += 1\n if object.is_a? Puppet::TransBucket\n buckets << object\n else\n objects << object\n if object.file == :funtest\n found << object\n end\n end\n end\n }\n\n top.flatten.each do |obj|\n assert(objects.include?(obj), \"Missing obj #{obj.type}[#{obj.name}]\")\n end\n\n\n assert_equal(\n found.length,\n top.flatten.find_all { |o| o.file == :funtest }.length,\n \n \"Found incorrect number of objects\")\n end",
"def run_tests\n desc = 'valid full tree'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(30)\n right = tree.insert_right(70)\n left.insert_left(10)\n left.insert_right(40)\n right.insert_left(60)\n right.insert_right(80)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\n\n desc = 'both subtrees valid'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(30)\n right = tree.insert_right(80)\n left.insert_left(20)\n left.insert_right(60)\n right.insert_left(70)\n right.insert_right(90)\n result = binary_search_tree?(tree)\n assert_false(result, desc)\n\n desc = 'descending linked list'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(40)\n left_left = left.insert_left(30)\n left_left_left = left_left.insert_left(20)\n left_left_left.insert_left(10)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\n\n desc = 'out of order linked list'\n tree = BinaryTreeNode.new(50)\n right = tree.insert_right(70)\n right_right = right.insert_right(60)\n right_right.insert_right(80)\n result = binary_search_tree?(tree)\n assert_false(result, desc)\n\n desc = 'one node tree'\n tree = BinaryTreeNode.new(50)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\nend",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_depth=\n @br.depth = 100\n end",
"def check_table_contents(id, state, timeout=nil, recurse=true)\r\n begin\r\n count = page_all_xpath(\"//table[@id='\" + id + \"']/tbody/tr\").count\r\n if state == \"empty\"\r\n if count == 1\r\n # Empty tables have a single row with a single indicator label in it\r\n indicator = page_all_xpath(\"//table[@id='\" + id + \"']/tbody/tr/td/div/div/div/div[@class='gwt-Label']\").count\r\n if indicator != 1\r\n # I only want to sleep if the initial check doesn't work, because it slows down the tests\r\n if (recurse)\r\n timeout = normalize_timeout(timeout)\r\n sleep(timeout)\r\n check_table_contents(id, state, timeout, false)\r\n else\r\n raise \"Expected empty table, but found rows\"\r\n end\r\n end\r\n elsif count > 1\r\n # I only want to sleep if the initial check doesn't work, because it slows down the tests\r\n if (recurse)\r\n timeout = normalize_timeout(timeout)\r\n sleep(timeout)\r\n check_table_contents(id, state, timeout, false)\r\n else\r\n raise \"Expected empty table, but found rows\"\r\n end\r\n end\r\n elsif state == \"not empty\"\r\n if count == 1\r\n # Empty tables have a single row with a single indicator label in it\r\n indicator = page_all_xpath(\"//table[@id='\" + id + \"']/tbody/tr/td/div/div/div/div[@class='gwt-Label']\").count\r\n if indicator == 1\r\n # I only want to sleep if the initial check doesn't work, because it slows down the tests\r\n if (recurse)\r\n timeout = normalize_timeout(timeout)\r\n sleep(timeout)\r\n check_table_contents(id, state, timeout, false)\r\n else\r\n raise \"Expected non-empty table, but did not find rows\"\r\n end\r\n end\r\n elsif count < 1\r\n # I only want to sleep if the initial check doesn't work, because it slows down the tests\r\n if (recurse)\r\n timeout = normalize_timeout(timeout)\r\n sleep(timeout)\r\n check_table_contents(id, state, timeout, false)\r\n else\r\n raise \"Expected non-empty table, but did not find rows\"\r\n end\r\n end\r\n end\r\n rescue Selenium::WebDriver::Error::StaleElementReferenceError\r\n retry\r\n end\r\n end",
"def valid_tree?\n true\n end",
"def valid_tree?\n true\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def test_044\n test_000\n login(\"root\",\"root\")\n register_master(\"normal\", MASTER_FILES[\"normal\"])\n master_chosen = Master.find(:last)\n all_directory_tree_of_master = DirectoryTree.find_all_by_fk_id(master_chosen)\n assert_not_equal all_directory_tree_of_master, []\n delete_master\n wait_for_text_present(_(\" deleted successfully!\"))\n all_directory_tree_of_master= DirectoryTree.find_all_by_fk_id(master_chosen)\n assert_equal all_directory_tree_of_master, []\n logout\n end",
"def leaf?; false end",
"def test_bfs(tree, location, expect_match = true)\n puts \"\\n-----------------------------------------------------------------\\n \"\n puts \"Testing bfs method...\"\n puts \"\\nInitial location: Tree Root = [#{tree.root.location.to_s}]\\n \"\n node_match = tree.bfs(location)\n results_match = true\n if expect_match\n if node_match.nil?\n results_match = false\n else\n puts \"Node match found for [#{location[0]}, #{location[1]}]\"\n node_match.show_stats\n results_match = false unless node_match.location == location\n end\n else\n puts \"No match found\"\n results_match = false unless node_match.nil?\n end\n puts \">>>>>> ERROR <<<<<\" unless results_match\n puts \"\\n-----------------------------------------------------------------\\n \"\nend",
"def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end",
"def on_worktree(branch, &block)\n zombie_check \n yield checkout(branch) \n end",
"def wait_until_not_full; end",
"def test_min_root_only_node\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.min\n end",
"def one_level\n improvement = false\n nb_passes = 0\n cur_mod = @graph.modularity\n new_mod = cur_mod\n begin\n cur_mod = new_mod\n nb_moves = 0\n nb_passes += 1\n @graph.nodes.shuffle.each do |node|\n orig_community = @graph.get_community node\n\n neighbour_communities = @graph.get_neighbour_comms node\n\n @graph.remove_node node, orig_community\n\n\n best_community = orig_community\n max_gain = 0.0\n\n neighbour_communities.each do |comm|\n mod_gain = @graph.modularity_gain node, comm\n if mod_gain > max_gain\n max_gain = mod_gain\n best_community = comm\n end\n end\n if best_community != orig_community\n nb_moves += 1\n improvement = true\n end\n\n @graph.insert_node node, best_community\n\n @graph.garbage_collect orig_community\n\n end\n new_mod = @graph.modularity\n end while nb_moves > 0 and new_mod - cur_mod >= MIN_INCREASE\n return improvement\n end",
"def do_refresh(recurse=true)\n Thread.new do\n file_tree_mutex.synchronize do\n @tree.refresh\n @tree.model.refilter\n @tree.expand_first_row\n end\n end\n end",
"def test_delete_node_tree_r_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [8, 10]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def check_snapshot(vmname, node)\n if node.name =~ /^prekernel/\n compare_time = Time.now - CLEAN_AFTER_DAYS * 24 * 60 * 60\n if compare_time > node.createTime\n puts 'Deleting snapshot for ' + vmname + ' | ' + node.name + ' | ' + node.createTime.iso8601\n\n snapshot_task = node.snapshot.RemoveSnapshot_Task(removeChildren: false)\n snapshot_task = snapshot_task.wait_for_completion\n end\n end\n\n unless node.childSnapshotList.empty?\n node.childSnapshotList.each { |item| check_snapshot(vmname, item) }\n end\nend",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def test_children\n #puts \"---------------test_children-----------------\"\n t= {}\n\n batch11 = MyResource.new :batch11\n batch12 = MyResource.new :batch12\n batch21 = MyResource.new :batch21\n batch22 = MyResource.new :batch22\n pos1 = MyResource.new :pos1, [ batch11, batch12 ]\n pos2 = MyResource.new :pos2, [ batch21, batch22 ]\n order = MyResource.new :order, [pos1, pos2]\n\n GraphBuilder::Builder.build do |b|\n t[:order] = [ b.add(Thing0.new(order)) ]\n \n b.children do |pos|\n t[pos.name] = b.add Thing1.new(pos)\n b.children do |batch|\n b1 = b.add Thing11.new(batch)\n b2 = b.add Thing12.new(batch)\n t[batch.name] = [b1, b2]\n end\n end\n t[:order] << b.add( Thing2.new(order))\n end\n\n r = Thing.links(t.values.flatten)\n assert_instance_of Thing0, t[:order].first\n assert_instance_of Thing2, t[:order].last\n assert_instance_of Thing1, t[:pos1]\n assert_instance_of Thing1, t[:pos2]\n assert_instance_of Thing11, t[:batch11].first\n assert_instance_of Thing12, t[:batch12].last\n assert_instance_of Thing11, t[:batch21].first\n assert_instance_of Thing12, t[:batch22].last\n\n assert r.include? [t[:order].first,t[:pos1]]\n assert r.include? [t[:order].first,t[:pos2]]\n assert r.include? [t[:pos1],t[:batch11].first]\n assert r.include? [t[:pos1],t[:batch12].first]\n assert r.include? [t[:pos2],t[:batch21].first]\n assert r.include? [t[:pos2],t[:batch22].first]\n assert r.include? [t[:batch11].first,t[:batch11].last]\n assert r.include? [t[:batch12].first,t[:batch12].last]\n assert r.include? [t[:batch21].first,t[:batch21].last]\n assert r.include? [t[:batch22].first,t[:batch22].last]\n assert r.include? [t[:batch11].last,t[:order].last]\n assert r.include? [t[:batch12].last,t[:order].last]\n assert r.include? [t[:batch21].last,t[:order].last]\n assert r.include? [t[:batch22].last,t[:order].last]\n\n assert_equal 14, r.size\n end",
"def test_load_works\n tree = BinarySearchTree.new\n tree.load\n assert tree.root.left_node != nil\n assert tree.root.right_node != nil\n end",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def trim_tree\n\t\t@corridor_seeds.each { |seed| check_branch(corridor_map[seed]) }\n\tend",
"def test_unbalanced_child_gets_returned_if_exists\n parent = @system.base\n assert_equal @system.get_by_name(\"ugml\"), @system.unbalanced_child(parent)\n end",
"def bfs(tree, value)\n q = MyQueue.new\n q.enqueue(tree)\n current_tree = q.dequeue() #need to do something when i dequeue \n \n while current_tree != nil\n puts current_tree.payload\n\n if current_tree.payload != value\n current_tree.children.each do |leaf|\n q.enqueue(leaf)\n end\n else\n q = MyQueue.new\n end\n current_tree = q.dequeue()\n end\nend",
"def init_simple_tree\n @root_org = Org.create(name: 'root')\n @lv1_child_org = Org.create(name: 'lv1')\n @lv1_child_org2 = Org.create(name: 'lv1-2')\n @lv2_child_org = Org.create(name: 'lv2')\n @lv2_child_org2 = Org.create(name: 'lv2-2')\n @lv2_child_org3 = Org.create(name: 'lv2-3')\n @lv2_child_org4 = Org.create(name: 'lv2-4')\n @lv3_child_org = Org.create(name: 'lv3')\n @lv3_child_org2 = Org.create(name: 'lv3-2')\n @lv4_child_org = Org.create(name: 'lv4')\n @lv4_child_org2 = Org.create(name: 'lv4-2')\n @lv5_child_org = Org.create(name: 'lv5')\n @lv5_child_org2 = Org.create(name: 'lv5-2')\n\n current_time = Time.now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @root_org.id,\n distance: 0,\n start_time: 10.minutes.ago(current_time),\n end_time: 1000.years.from_now,\n scope_name: 'default'\n )\n\n # 10 minutes ago\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 2,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n # now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org3.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org3.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org4.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org4.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv3_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org2.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\nend",
"def check_integrity(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"stray node found in level: #{l} which is #{list.to_a(nil,nil,nil,l)}\" if !difference.empty? \n expect(difference).to match_array([])\n end\nend",
"def check_task_tree(appeal, verbose: true)\n CheckTaskTree.call(appeal, verbose: verbose)\n end",
"def valid_tree?\n true\n end",
"def test_size\n assert_equal(1, @root.size, \"Root's size should be 1\")\n setup_test_tree\n\n assert_equal(5, @root.size, \"Root's size should be 5\")\n assert_equal(2, @child3.size, \"Child 3's size should be 2\")\n end",
"def test_project_descendants_recalculator(project)\n Key.batch_recalculate_ready!(project)\n\n project.commits.find_each do |commit|\n CommitRecalculator.new.perform(commit.id)\n end\n\n project.articles.find_each do |article|\n ArticleRecalculator.new.perform(article.id)\n end\n end",
"def test_branch\n #puts \"---------------test_branch-----------------\"\n t1= nil\n t2 = nil\n t11 = nil\n t12 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12])\n assert_equal 4, r.size\n assert r.include? [t1,t11]\n assert r.include? [t1,t12]\n assert r.include? [t11,t2]\n assert r.include? [t12,t2]\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def wait\n true\n end",
"def grow_tree\n dataset.order_transaction_items(candidate_items).each do |transaction|\n add_transaction(transaction, root)\n end\n calculate_header_support\n end",
"def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end",
"def test_current_version\n check_current_version(current_nodes(:visible_node))\n check_current_version(current_nodes(:used_node_1))\n check_current_version(current_nodes(:used_node_2))\n check_current_version(current_nodes(:node_used_by_relationship))\n check_current_version(current_nodes(:node_with_versions))\n end",
"def floodfill_tree bn_id, &blk\n info \"Fill #{bn_id}\"\n return bn_id if node_visited?(bn_id)\n _q.push(bn_id)\n\n index = 0\n while _q.length > 0 do\n #bn = blk.call(bn_id)\n bns = Http.get_bns _q\n bns.each do |bn|\n bn_data = get_node_data_from_xml_doc(bn)\n set_node(bn_data)\n children = get_children_from_xml_doc(bn).map do |child_bn| \n get_node_data_from_xml_doc(child_bn)\n end\n children.each do |child|\n #floodfill_tree child[:id], &blk\n _q.push(child[:id])\n add_child bn_data[:id], child[:id]\n end\n ancestors = get_ancestors_from_xml_doc(bn)\n ancestors.each do |parent|\n parent_data = get_node_data_from_xml_doc parent\n #floodfill_tree parent_data[:id], &blk\n _q.push(parent_data[:id])\n add_ancestor bn_data[:id], parent_data[:id]\n # First 2 levels of ancestors are virtual nodes\n # Add them with this request\n current_parent_bn_id = parent_data[:id]\n grandparent = get_ancestors_from_xml_doc(parent)\n while grandparent.length > 0\n # MAybe Bug\n grandparent_data = get_node_data_from_xml_doc parent\n set_node grandparent_data\n add_ancestor current_parent_bn_id, grandparent_data[:id]\n current_parent_bn_id = grandparent_data[:id]\n grandparent = get_ancestors_from_xml_doc(grandparent)\n end\n end\n # a node is visited when all neighbours are visited\n visit_node bn_data[:id]\n end\n info \"To process #{_q.inspect}\"\n _q.reject!{|e| node_visited?(e)}\n info \"To process #{_q.length} node(s)\"\n index += 1\n save if (index%100 == 0)\n end\n save\n end",
"def test_depth_simple\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,200]\n end\n assert_equal(100, bbox.depth,\n 'Failed in test_depth_simple' )\n end",
"def test_slide_1\n TaxonName.slide(2, 3)\n assert_equal 6, @child_middle.reload.l\n TaxonName.slide(-2, 3)\n assert @root_node.reload.check_subtree\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def work\n self.busy = true\n check_for_new_commits_on_branches\n self.busy = false\n end",
"def test_delete_node_tree_l_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [10, 8]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def redraw_tree?\n ### DISCUSS: how to set this flag from outside?\n params[:reload_tree] || false\n end",
"def redraw_tree?\n ### DISCUSS: how to set this flag from outside?\n params[:reload_tree] || false\n end",
"def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end",
"def test_check_block_num_equal\r\n assert_equal true, @g.check_block_num(1, 1)\r\n end",
"def test_024\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #The directory/file names which were being changed into the state\n #where it does not check at the information dialog\n #which clicks analyze_deny_files and comes out are enumerated.\n\n click $xpath[\"task\"][\"analyze_deny_files\"]\n sleep 3\n\n assert is_text_present(\"sample_c/Makefile\")\n\n\n # logout\n logout\n\n end",
"def freezed?\n false\n end",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def got_lock?(lock_attempt, zk, config)\n children = zk.get_children(:path => config[:root])[:children].sort\n puts \"children found are #{children}\" if config[:verbose]\n mylocks = children.select {|child| child.start_with?(config[:lockname] + \".\") }\n puts \"Testing my lock (#{lock_attempt[:path]} against the first child (#{config[:root]}/#{mylocks.first})\" if config[:verbose]\n return lock_attempt[:path] == \"#{config[:root]}/#{mylocks.first}\"\nend",
"def test(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"test failed level #{l} ,inconsistent node(s) #{difference}\" if (difference.count != 0)\n end\n puts \"test complete\"\nend",
"def test_return_method_truthy\n @tree.insert(\"a\")\n @tree.insert(\"c\")\n assert_equal true, @tree.includes?(\"c\")\n end",
"def unit_test_binary_tree\n node_a = Node.new('A', nil, nil, nil)\n node_b = Node.new('B', nil, nil, nil)\n node_c = Node.new('C', nil, nil, nil)\n node_d = Node.new('D', nil, nil, nil)\n node_e = Node.new('E', nil, nil, nil)\n node_f = Node.new('F', nil, nil, nil)\n node_g = Node.new('G', nil, nil, nil)\n node_h = Node.new('H', nil, nil, nil)\n node_i = Node.new('I', nil, nil, nil)\n node_j = Node.new('J', nil, nil, nil)\n\n tree = Tree.new(nil)\n\n p \"-------------------- BEGIN CONSTRUCTING TREE -------------------- \"\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A D I \"\n p \" // \\\\ // \"\n p \" C E H \"\n\n p \"-------------------- END CONSTRUCTING TREE -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN INRODER TREE WALK -------------------- \"\n p inorder_tree_walk(tree.root)\n p \"-------------------- END INRODER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN PREORDER TREE WALK -------------------- \"\n p preoder_tree_walk(tree.root)\n p \"-------------------- END PREORDER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN POSTORDER TREE WALK -------------------- \"\n p postorder_tree_walk(tree.root)\n p \"-------------------- END PREORDER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN RECURSIVE TREE SEARCH -------------------- \"\n p tree_search(tree.root, 'I')\n p \"-------------------- END RECURSIVE TREE SEARCH -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN ITERATIVE TREE SEARCH -------------------- \"\n p iterative_tree_search(tree.root, 'I')\n p \"-------------------- END ITERATIVETREE SEARCH -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR TREE MIN -------------------- \"\n p tree_minimum(tree.root)\n p \"-------------------- END SEARCHING FOR TREE MIN -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING TREE MAX -------------------- \"\n p tree_maximum(tree.root)\n p \"-------------------- END SEARCHING TREE MAX -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR SUCCESSOR -------------------- \"\n p tree_successor(node_g)\n p \"-------------------- END SEARCHING FOR SUCCESSOR -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR PREDECESSOR -------------------- \"\n p tree_predecessor(node_g)\n p \"-------------------- END SEARCHING FOR PREDECESSOR -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE INSERTION -------------------- \"\n tree_insert(tree, node_j)\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A D I \"\n p \" // \\\\ // \\\\ \"\n p \" C E H J \"\n p \"-------------------- END NODE INSERTION -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE DELETION (SUCCESSOR) -------------------- \"\n tree_delete(tree, node_d)\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A E I \"\n p \" // // \\\\ \"\n p \" C H J \"\n p \"-------------------- END NODE DELETION (SUCCESSOR) -------------------- \"\n preoder_tree_walk(tree.root)\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE DELETION (PREDECESSOR) -------------------- \"\n tree_delete_predecessor(tree, node_b)\n p \" F \"\n p \" // \\\\ \"\n p \" A G \"\n p \" \\\\ \\\\ \"\n p \" E I \"\n p \" // // \\\\ \"\n p \" C H J \"\n p \"-------------------- END NODE DELETION (PREDECESSOR) -------------------- \"\n preoder_tree_walk(tree.root)\n end",
"def test_sort_by_ancestry_with_block_full_tree\n AncestryTestDatabase.with_model :extra_columns => {:rank => :integer} do |model|\n n1, n2, n3, n4, n5, n6 = build_ranked_tree(model)\n\n records = model.sort_by_ancestry(model.all.order(:id => :desc), &RANK_SORT)\n assert_equal [n1, n5, n3, n2, n4, n6].map(&:id), records.map(&:id)\n end\n end",
"def test_delete_node_in_empty_tree\n @tree_empty.delete(0)\n assert_equal 0,\n @tree_empty.node_count,\n \"deleting a node from an empty tree is a NO-OP, but got something\"\n end",
"def test_node_starts_with_empty_branches\n node = Node.new(50, \"movie a\")\n refute node.left_node\n refute node.right_node\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def test_depth_zero\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,100]\n end\n assert_equal(0, bbox.depth,\n 'Failed in test_depth_zero' )\n end",
"def test_freeze\n\t\tEM::DnsCache.add_nameserver TestNameserver\n\t\tEM::DnsCache.verbose\n\n\t\tout = nil\n\n\t\tEM.run {\n\t\t\td = EM::DnsCache.resolve_mx \"steamheat.net\"\n\t\t\td.errback {EM.stop}\n\t\t\td.callback {|r|\n\t\t\t\tout = r\n\t\t\t\tEM.stop\n\t\t\t}\n\t\t}\n\n\t\tassert out\n\t\tassert( out.length > 0)\n\t\tassert_raise( TypeError ) {\n\t\t\tout.clear\n\t\t}\n\tend",
"def test_019\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #Click link M of a directory\n click $xpath[\"task\"][\"m_link\"]\n sleep 2\n\n #The name of the directory which pushed [M] goes into the field of right-hand side make_root.\n assert_equal \"sample_c/\", get_value( $xpath[\"task\"][\"make_root_link\"])\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end",
"def test_023\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #The directory/file names which were being changed into the check state\n #at the information dialog which clicks analyze_allow_files\n #and comes out are enumerated.\n click $xpath[\"task\"][\"analyze_allow_file_link\"]\n sleep 3\n\n assert !is_text_present(\"sample_c/Makefile\")\n\n # logout\n logout\n\n end",
"def test_dead_lock\n begin\n Thread.current.name = \"MainThread!\"\n z = Thread.new{Thread.stop}\n a, b = Thread.new { 1 until b; b.join }, Thread.new { 1 until a; a.join }\n a.name = \"aaaaa\"\n b.name = \"bbbbb\"\n z.name = \"zzzz\"\n a.join\n\n flunk 'should dead lock'\n rescue Exception => e\n error_info = e.inspect\n assert /No live threads left. Deadlock\\?/ =~ error_info\n assert error_info.lines.size > 50\n end\nend",
"def refork; end",
"def test_check_block_num_unequal\r\n assert_nil nil, @g.check_block_num(1, 0)\r\n end",
"def test_widget_session_cleanup\n r = cell(:my_test, :some, 'root')\n r << a= cell(:my_test, :some, 'a')\n r << b1= cell(:my_test, :some, 'b')\n a << b2= cell(:my_test, :some, 'b')\n \n \n freeze_tree_for(r, session)\n \n r = thaw_tree_for(session, controller)\n r.find_by_id('b').removeFromParent!\n \n freeze_tree_for(r, session)\n assert_equal session['apotomo_widget_content'].size, 3\n #assert session['apotomo_widget_content'].reject?('b')\n end",
"def test_suicide_duty()\n [1, 2].each() do |concurrent_duties|\n [true, false].each() do |persistent_workers|\n assert_nothing_thrown() do\n s = generate_spawner(concurrent_duties, persistent_workers, 0,\n @jobs_log_file, @spawner_log_file)\n\n generate_tasks_addition(s, 2, true, 2) {exit 42}\n end\n end\n end\n end"
] |
[
"0.5896011",
"0.5835977",
"0.5793127",
"0.56592774",
"0.5588644",
"0.5534555",
"0.55041546",
"0.5460143",
"0.54390097",
"0.5420358",
"0.54201794",
"0.54101765",
"0.5403881",
"0.5403881",
"0.53922224",
"0.5389457",
"0.5378399",
"0.5378399",
"0.5378399",
"0.5332773",
"0.5303974",
"0.5301747",
"0.52928174",
"0.52864367",
"0.5282271",
"0.527596",
"0.5273323",
"0.5262601",
"0.5262601",
"0.52607334",
"0.5257",
"0.52539957",
"0.52503574",
"0.5237466",
"0.52313524",
"0.5212956",
"0.520943",
"0.51994616",
"0.51994616",
"0.5186241",
"0.51822764",
"0.51789415",
"0.516892",
"0.51504564",
"0.5143854",
"0.51340777",
"0.5130394",
"0.5127476",
"0.5122134",
"0.51209795",
"0.5119323",
"0.5112452",
"0.5109398",
"0.51092625",
"0.510218",
"0.5100803",
"0.5099905",
"0.5088567",
"0.5081787",
"0.5080725",
"0.50714993",
"0.5064835",
"0.50637054",
"0.506307",
"0.50589085",
"0.5051963",
"0.5037013",
"0.5032518",
"0.5030858",
"0.500943",
"0.50078624",
"0.5005943",
"0.50034374",
"0.50025266",
"0.49991697",
"0.498642",
"0.49831983",
"0.49831983",
"0.49712095",
"0.4970207",
"0.49682373",
"0.49616507",
"0.49566725",
"0.49562204",
"0.49554357",
"0.49548727",
"0.4954165",
"0.49535257",
"0.49517438",
"0.49508488",
"0.49451634",
"0.49427813",
"0.4941394",
"0.4939393",
"0.4938268",
"0.4929984",
"0.49294218",
"0.4926507",
"0.49219593",
"0.49171427"
] |
0.7029016
|
0
|
Test whether the content is accesible
|
def test_content
pers = Person::new("John", "Doe")
@root.content = pers
assert_same(pers, @root.content, "Content should be the same")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_access?\n true\n end",
"def has_access?\n true\n end",
"def can_read_content?(user)\n released_for_student?(user) || can_edit?(user)\n end",
"def publicly_available?\n return false unless access_rights.present?\n\n access_rights.none? do |value|\n value == 'deny' || %w[allow:icus allow:pdus].include?(value)\n end\n end",
"def can_access?(space = object)\n space.accessible_by_user?(current_user)\n end",
"def check_accessible\n if current_user\n myaction=Action.find_controller_action(params[:controller], params[:action])\n raise \"Page not found\" unless !myaction || myaction.accessible(current_user) || Group.find(2).has_user(current_user) # this is a nasty hack to stop errors because there are links to actions accessible only by users. Need to sort out access management!!\n end\n end",
"def allow_access\n !@current_user.nil?\n end",
"def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end",
"def can_access?\n allows_current_user_access_to? :access\n end",
"def publicly_accessible?\n codelet.publicly_accessible?\n end",
"def check_can_access\n res = false\n read_actions = [ \"index\", \"list\", \"edit\" ]\n new_actions = [ \"new\", \"create\" ]\n edit_actions = [ \"edit\", \"update\", \"destroy\", \"update_logo\" ]\n\n res ||= (action_name == \"show_logo\")\n res ||= current_user.admin?\n\n if current_user.option_externalclients?\n res ||= (current_user.read_clients? and read_actions.include?(action_name))\n res ||= (current_user.edit_clients? and edit_actions.include?(action_name))\n res ||= (current_user.create_clients? and new_actions.include?(action_name))\n end\n\n if !res\n flash[\"notice\"] = _(\"Access denied\")\n redirect_from_last\n end\n end",
"def can_access?(user)\n return true if self.class.standalone_page_available_to_user self, user\n\n user.has_access_to?(:read, :standalone_page, :_all_standalone_pages_)\n end",
"def allow_access\n !current_cas_user.nil?\n end",
"def show\n return unless check_permission\n end",
"def needs_permission_badge?\n solr_document.visibility != Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n end",
"def has_access\n if !@contest.is_organized_by_or_admin(current_user.sk) && @contestproblem.at_most(:not_started_yet)\n render 'errors/access_refused' and return\n end\n end",
"def can_edit?\n head(:forbidden) unless current_user.review_space_admin? || @space.editable_by?(current_user)\n end",
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def open_access_pending?\n !open_access? && request_for_visibility_change==Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n end",
"def restricted?\n page.restricted?\n end",
"def accessible\n true \n end",
"def allow_access_to_data?\n type == :normal\n end",
"def read_access_check\n resource_check('read')\n end",
"def read_access_check\n resource_check('read')\n end",
"def read_access_check\n resource_check('read')\n end",
"def has_access_to(cp)\n if can_review(cp) || can_edit(cp) || is_admin\n true\n end\n\n end",
"def ensure_can_see!(obj)\n raise Discourse::InvalidAccess.new(\"Can't see #{obj}\") unless can_see?(obj)\n end",
"def check_visibility\n set_problem\n viewable = begin\n unless @problem.hide\n true\n else\n if logged_in? && current_user.is_admin?\n true\n else\n false\n end\n end\n end\n\n unless viewable\n render status: :forbidden, nothing: true\n return\n end\n end",
"def authorize_manage_obj_content!\n authorize! :manage_content, @object\n end",
"def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_user), notice: \"You can't view this page, contact your box owner\"\n\t\tend\t\n\tend",
"def authorized?\n if !@extra_page.editable_by? current_user, current_cookbook\n redirect_to sections_path, alert: \"You are not allowed to edit this extra page.\"\n end\n end",
"def check_write_access(obj)\n return obj unless LinkedData.settings.enable_security\n if obj.is_a?(LinkedData::Models::Base) && obj.write_restricted?\n writable = obj.writable?(env[\"REMOTE_USER\"])\n error 403, \"Access denied for this resource\" unless writable\n end\n end",
"def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend",
"def check_permissions\n unless can_edit? @post\n flash.now[:warning] = \"You can't edit that post.\"\n redirect_to :action => 'show'\n return false\n end\n end",
"def check_permissions\n unless can_edit? @post\n flash[:warning] = \"You can't edit that post.\"\n redirect_to :action => 'show'\n return false\n end\n end",
"def check_access\n permission_denied unless can_census?(year)\n end",
"def is_publicly_visible?\n return false if visibility.nil?\n return( visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC )\n end",
"def format_accessible?(format = :html)\n session[:return] = request.request_uri\n\n return true if CACM::CRAWLER_IPS.include?(request.remote_ip)\n if CACM::CRAWLER_AGENTS =~ request.user_agent\n render :action => 'barrier.html.haml', :content_type => 'text/html'\n return false\n end\n return true unless @article.is_a?(DLArticle) # don't authorize for 3rd party content\n unless session_valid? and current_member.can_access?(@article, format)\n @session_expired = true unless session_valid?\n render :action => 'barrier.html.haml', :content_type => 'text/html'\n false\n else\n true\n end\n end",
"def read_allowed?(user)\n true\n end",
"def enforce_show_permissions(opts={})\n permissions = current_ability.permissions_doc(params[:id])\n if permissions.under_embargo? && !can?(:edit, permissions)\n raise Hydra::AccessDenied.new(\"This item is under embargo. You do not have sufficient access privileges to read this document.\", :edit, params[:id])\n end\n unless can? :read, permissions \n raise Hydra::AccessDenied.new(\"You do not have sufficient access privileges to read this document, which has been marked private.\", :read, params[:id])\n end\n end",
"def public_access?(perm_symbol)\n obj = find_permission_object(perm_symbol)\n obj.nil? ? false : obj.public_access? \n end",
"def gr_is_visible?\n eval_policy(:read_access)\n end",
"def fully_public?\n public && public_write\n end",
"def shared_access_allowed\n @settings.get_value(\"Shared Access\") == \"true\"\n end",
"def permission_required \n render_403 unless admin? || @user == current_user\n end",
"def allowed?\n true\n end",
"def allowed?\n true\n end",
"def allowed?\n true\n end",
"def publicly_viewable(path)\n %w(disclaimer about copyright privacy editorial users)\n .include?(path.split('/').first) || path.blank?\n end",
"def can_access?(user)\n user == self.user\n end",
"def revision_authorized?\n authorized_for?(:action => :read)\n end",
"def user_can_see?(user)\n !self.private || self.is_owner?(user)\n end",
"def check_user_rights\n if( params[:id] && !admin_authorized? )\n @bundle = Bundle.find(params[:id])\n if( ! @bundle.public )\n if( @bundle.created_by_user_id != @user.id )\n \t\t\t\trender :action => \"not_allowed\" \n end\n end\n end\n end",
"def show\n\t\traise CanCan::AccessDenied if !Presupuesto.accessible_by(current_ability, :show).include?(@presupuesto) \n end",
"def permission?()\n return nil\n end",
"def can_access?(kase)\n ca = self.access_to?(kase)\n ca || (!ca && (self.total_contacts_count > 0 || self.can_purchase_flex_contacts? || self.unlimited_premium_contacts?))\n end",
"def enforce_show_permissions(_opts = {})\n permissions = current_ability.permissions_doc(solr_id)\n if (permissions['read_access_group_ssim'].present? && permissions['read_access_group_ssim'].include?('registered')) || can?(:discover, permissions)\n permissions\n else\n raise Blacklight::AccessControls::AccessDenied.new('You do not have sufficient access privileges to view this document, which has been marked private.', :discover, params[:id])\n end\n end",
"def accessible?\n !!refs\n rescue Inaccessible\n false\n end",
"def open_to_public?\n allow_external_students? || allow_external_volunteers?\n end",
"def check_api_access\n current_resource_owner&.can_use_api?\n end",
"def ensure_authorized_to_view\n @listing = Listing.find(params[:id])\n unless @listing.visible_to?(@current_user, @current_community)\n puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>unless\"\n if @listing.visibility.eql?(\"everybody\")\n # This situation occurs when the user tries to access a listing\n # via a different community url.\n flash[:error] = \"this_content_is_not_available_in_this_community\"\n puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>if\"\n redirect_to community_home_path and return\n elsif @current_user\n puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>elsif\"\n flash[:error] = \"you_are_not_authorized_to_view_this_content\"\n redirect_to community_home_path and return\n else\n puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>else\"\n session[:return_to] = request.fullpath\n flash[:warning] = \"you_must_log_in_to_view_this_content\"\n redirect_to login_path and return\n end\n end\n end",
"def restricted_by_location?\n rights.restricted_by_location?(file_name)\n end",
"def has_resource_permission()\n resource = resource().find(params[:id])\n unless (current_user.admin? or current_user == resource.user)\n render 'shared/403', :status => 403\n return false\n end\n return true\n end",
"def has_access? c\n access_rights[controller2right c] == '1'\n end",
"def mayView? ( other_user )\n if ( (not other_user.valid?) or ( other_user.is_a?(User) == false ) )\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"basic check failed\"\n # d other_user.type\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n return false\n end\n user = getUser()\n if ( other_user == user )\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"same user as owner\"\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n return true\n end\n if ( ( self.public_policy == Dfile::PP_MAYVIEW ) or ( self.public_policy == Dfile::PP_MAYEDIT ) )\n return true\n end\n if self.special_users\n special = self.special_users[other_user.id.to_s]\n if special\n if ( ( special == Dfile::PP_MAYVIEW ) or ( special == Dfile::PP_MAYEDIT ) )\n return true\n else\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"User has special permission but not right one\"\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\" \n end\n else\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"User has no special permission\"\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\" \n end\n \n else\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"no special permissions\"\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\" \n end\n return false\n end",
"def tiene_permiso?\n if not protect?(action_name)\n return true\n end\n if @session['user'] and autorizado?(@session['user'], controller_name)\n return true\n end\n store_location\n access_denied\n return false\n end",
"def has_access\n accessible = subject_has_access_to_resource?(params[:id], params[:resource])\n if accessible == true # should code a comparison agains ruby regular expressions here\n render :text => \"<a>1</a>\" \n return\n end\n # if no matching resouces found by the end of the iteration, return false\n render :text => \"<a>0</a>\"\n end",
"def customize_authorized?\n authorized_for?(:action => :read)\n end",
"def editable_check(_traversal_env)\n Result::DENY\n end",
"def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end",
"def check_authorization\n @can_edit = can_blank_timetable?('edit')\n @can_show = can_blank_timetable?('show')\n end",
"def is_view_permitted?(given_user = nil)\r\n return false unless self.active?\r\n \r\n given_user ||= self.current_user\r\n \r\n # If item is public, no need for further permission checks\r\n return true if self.public? && self.user && self.user.public? \r\n \r\n # Base case of identity, no need to check relationships\r\n return true if given_user && ((given_user.id == self.author_id) || (given_user.id == self.foruser_id) || given_user.is_self_or_owner?(self.user))\r\n\r\n # Special case -- allow recipient and owners to see private messages\r\n if self.is_a?(Pvtmessage)\r\n return true if given_user.is_self_or_owner?(self.foruser) || given_user.is_self_or_owner?(self.user)\r\n return false\r\n end\r\n\r\n return true if given_user.admin?\r\n \r\n # Otherwise no can do if only my owner can see it (if you got to here, you aren't my owner)\r\n return false if self.restriction_level == Relationshiptype.nobody\r\n\r\n # Content of private or blocked projects cannot be seen\r\n return false if self.user && !self.user.is_view_permitted?\r\n\r\n # Fine, we'll actually run some DB queries...\r\n return Relationship.has_follower?(self.user, given_user, self.levels_can_see)\r\n end",
"def can_access?\n raise Acme::Distributed::ConnectorError, \"#can_access? not implemented in derived class\"\n end",
"def check_permission\n unless current_user.is_admin == 1\n redirect_to \"/\", warning: \"You don't have permission to access that page.\"\n end\n end",
"def attackable?\n true\n end",
"def protect?(action)\n true\n end",
"def check_update_permission\n return if owner? || @article.is_public_editable\n redirect_to articles_url\n end",
"def access_control\n \n end",
"def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end",
"def has_access\n if !current_user\n redirect_to \"/error\"\n return false;\n end\n return true\n end",
"def has_access?( action )\n unless @sir_log.permitted_to_access?( current_user.id )\n render_no_access\n return false\n end\n return true if [ 'index', 'new', 'create', 'show_stats' ].include?( action_name )\n unless current_user.permission_to_access( feature_identifier, action, @sir_item.group_id )\n render_no_permission \n return false \n end\n return true\n end",
"def has_access?(id)\n unless current_is?(id)\n flash[:alert]=\"Sorry you don't have accesss to that.\"\n return false\n end\n true\n end",
"def check_ownership \t\n \taccess_denied(:redirect => @check_ownership_of) unless current_user_owns?(@check_ownership_of)\n end",
"def is_editable?\n is_public\n end",
"def accessible_by?(context)\n return false unless context.logged_in?\n\n accessible_by_user?(context.user)\n end",
"def access_permissions\n return true if authenticated?\n render(plain: 'Unauthorized!', status: :unauthorized)\n end",
"def user_can_edit\n unless logged_in? and can_edit?\n respond_with_error(\n \"You must have editor permissions to edit this content.\", \n root_path)\n end\n end",
"def accessible?\n admin? || owner? || @project.is_open_source?\n end",
"def check_permissions\n unless current_user.is_organizer?\n redirect_to index_path, alert: 'You do not have the permissions to visit this section of hardware.'\n end\n end",
"def show\n authorize @moderation\n end",
"def show\n authorize @page_content.page, :show?\n end",
"def can_view?(object)\n false\n end",
"def protect?(action)\n\t\ttrue\n\tend",
"def public?\n self.mode == PUBLIC\n end",
"def read_permitted?\n return (acting_user.administrator? || true)\n end",
"def handle_content_exclusions\r\n @entry ||= Content.find(@content_id || params[:id])\r\n raise Kroogi::NotFound if @entry.class.name.to_s == 'ImageThumbnail'\r\n raise Kroogi::NotFound if @entry.featured_album?\r\n @entry.calc_in_inbox_by_user_data\r\n raise Kroogi::NotPermitted unless @entry.is_view_permitted? ||\r\n (permitted?(current_user, :moderate) && @entry.restriction_level >= Content.allow_moderators_to_view_this_circle_and_further) ||\r\n (current_user.admin? && params[:force_view])\r\n unless @entry.active?\r\n flash[:warning] = \"This content item has been blocked by the moderation team, and is no longer available for viewing\".t\r\n if permitted?(current_user, :moderate)\r\n return false\r\n else\r\n redirect_to(explore_path) and return false\r\n end\r\n end\r\n end",
"def checkUserPageAccess(user, pagePath)\n return false\n end",
"def publicly_accessible\n data[:publicly_accessible]\n end",
"def publicly_accessible\n data[:publicly_accessible]\n end",
"def protects?(thing)\n false\n end",
"def privileged_access?\n connected? || PrismicService.access_token\n end"
] |
[
"0.7377797",
"0.7377797",
"0.71611613",
"0.7152097",
"0.7019996",
"0.6942628",
"0.69218874",
"0.68518776",
"0.6823548",
"0.6812201",
"0.6762285",
"0.674089",
"0.67158216",
"0.6711801",
"0.6688084",
"0.6686559",
"0.66835994",
"0.66764975",
"0.66746205",
"0.6665309",
"0.66631347",
"0.6654438",
"0.6627977",
"0.6627977",
"0.6627977",
"0.6618351",
"0.66183186",
"0.6609346",
"0.65729433",
"0.6551966",
"0.65265054",
"0.64654815",
"0.6445521",
"0.6432352",
"0.6429482",
"0.6425623",
"0.6412324",
"0.6403361",
"0.6398528",
"0.6397295",
"0.6395475",
"0.63953805",
"0.6394933",
"0.6392347",
"0.6391185",
"0.63872105",
"0.63872105",
"0.6382098",
"0.6380517",
"0.6379907",
"0.6352463",
"0.63497853",
"0.6348605",
"0.6346103",
"0.6327758",
"0.6323636",
"0.6321254",
"0.6320554",
"0.6313183",
"0.63124925",
"0.62995225",
"0.6291325",
"0.6285827",
"0.62832296",
"0.6281417",
"0.62766653",
"0.6269307",
"0.6266616",
"0.6265885",
"0.626315",
"0.6262844",
"0.6261047",
"0.6253039",
"0.623997",
"0.62355036",
"0.62344277",
"0.62284356",
"0.6226935",
"0.6222624",
"0.6221548",
"0.62195754",
"0.62163633",
"0.62110734",
"0.62098426",
"0.62063736",
"0.62018806",
"0.61963385",
"0.61949044",
"0.6188391",
"0.61864334",
"0.61848515",
"0.61806875",
"0.6174705",
"0.61728907",
"0.61706203",
"0.616952",
"0.61660665",
"0.6161592",
"0.6161592",
"0.61534697",
"0.6153282"
] |
0.0
|
-1
|
Test the depth computation algorithm. Note that this is an incorrect computation and actually returns height+1 instead of depth. This method has been deprecated in this release and may be removed in the future.
|
def test_depth
begin
require 'structured_warnings'
assert_warn(DeprecatedMethodWarning) { do_deprecated_depth }
rescue LoadError
# Since the structued_warnings package is not present, we revert to good old Kernel#warn behavior.
do_deprecated_depth
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_depth\n raise \"Not implemented\"\n end",
"def depth()\n #This is a stub, used for indexing\n end",
"def depth\n @traversal_position.depth\n end",
"def depth\n n = 0\n p, q = lftp, lftq\n while p != 0\n x = p.inverse(q)\n p, q = (x * p - 1) / q, x\n n += 1\n end\n n\n end",
"def depth_max; depths.max end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def depth_min; depths.min end",
"def current_depth\n 0\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def depth\n return 0 if nil?\n\n @accumulator_depth = 1\n depth_aux(self, @accumulator_depth)\n @accumulator_depth\n end",
"def my_depth\n 1\n end",
"def depth\n self[:depth]\n end",
"def depth; end",
"def depth\n depth_support(self.root)\n end",
"def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end",
"def height\n return 0 if @root == nil\n return 1 if @root && (@root.left == nil && @root.right == nil)\n height_helper(@root, 0)\n end",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end",
"def do_deprecated_depth\n assert_equal(1, @root.depth, \"A single node's depth is 1\")\n\n @root << @child1\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @root << @child2\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @child2 << @child3\n assert_equal(3, @root.depth, \"This should be of depth 3\")\n assert_equal(2, @child2.depth, \"This should be of depth 2\")\n\n @child3 << @child4\n assert_equal(4, @root.depth, \"This should be of depth 4\")\n end",
"def height_with_recursion(root)\n return 0 unless root\n leftDepth = height_with_recursion(root.left)\n rightDepth = height_with_recursion(root.right)\n (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1\n end",
"def depth(value)\n node = find(value)\n find_depth(node)\n end",
"def total_depth(depth_phase1, max_depth)\n mv = 0\n d1 = 0\n d2 = 0\n max_depth_phase2 = [10, max_depth - depth_phase1].min # max 10 moves in phase 2\n depth_phase1.times do |i|\n mv = 3 * move_axis[i] + move_power[i] - 1\n urf_to_dlf[i + 1] = Cache.urf_to_dlf_move[urf_to_dlf[i]][mv]\n fr_to_br[i + 1] = Cache.fr_to_br_move[fr_to_br[i]][mv]\n parity[i + 1] = Cache.parity_move[parity[i]][mv]\n end\n\n d1 = Cache::BasePrune.get_pruning(\n Cache.slice_urf_to_dlf_parity_prune,\n (Cache::BaseCache::N_SLICE2 * urf_to_dlf[depth_phase1] + fr_to_br[depth_phase1]) * 2 + parity[depth_phase1]\n )\n return -1 if d1 > max_depth_phase2\n\n depth_phase1.times do |i|\n mv = 3 * move_axis[i] + move_power[i] - 1\n ur_to_ul[i + 1] = Cache.ur_to_ul_move[ur_to_ul[i]][mv]\n ub_to_df[i + 1] = Cache.ub_to_df_move[ub_to_df[i]][mv]\n end\n\n ur_to_df[depth_phase1] = Cache.merge_ur_to_ul_and_ub_to_df[ur_to_ul[depth_phase1]][ub_to_df[depth_phase1]]\n\n d2 = Cache::BasePrune.get_pruning(\n Cache.slice_ur_to_df_parity_prune,\n (Cache::BaseCache::N_SLICE2 * ur_to_df[depth_phase1] + fr_to_br[depth_phase1]) * 2 + parity[depth_phase1]\n )\n return -1 if d2 > max_depth_phase2\n\n min_dist_phase2[depth_phase1] = [d1, d2].max\n return depth_phase1 if min_dist_phase2[depth_phase1] == 0 #already solved\n\n # set up search\n depth_phase2 = 1\n n = depth_phase1\n busy = false\n move_power[depth_phase1] = 0\n move_axis[depth_phase1] = 0\n min_dist_phase2[n + 1] = 1 # else failure for depth_phase2=1, n=0\n ####\n\n while true\n while true\n if depth_phase1 + depth_phase2 - n > min_dist_phase2[n + 1] and !busy\n if move_axis[n] == 0 || move_axis[n] == 3\n n += 1\n move_axis[n] = 1\n move_power[n] = 2\n else\n n += 1\n move_axis[n] = 0\n move_power[n] = 1\n end\n else\n if move_axis[n] == 0 || move_axis[n] == 3\n move_power[n] += 1\n else\n move_power[n] += 2\n end\n\n if move_power[n] > 3\n while true\n # increment axis\n move_axis[n] += 1\n if move_axis[n] > 5\n if n == depth_phase1\n if depth_phase2 >= max_depth_phase2\n return -1\n else\n depth_phase2 += 1\n move_axis[n] = 0\n move_power[n] = 1\n busy = false\n break\n end\n else\n n -= 1\n busy = true\n break\n end\n else\n if move_axis[n] == 0 || move_axis[n] == 3\n move_power[n] = 1\n else\n move_power[n] = 2\n end\n\n busy = false\n end\n\n break unless n != depth_phase1 && (move_axis[n - 1] == move_axis[n] || move_axis[n - 1] - 3 == move_axis[n])\n end\n else\n busy = false\n end\n end\n\n break unless busy\n end\n\n # compute new coordinates and new minDist\n mv = 3 * move_axis[n] + move_power[n] - 1\n urf_to_dlf[n + 1] = Cache.urf_to_dlf_move[urf_to_dlf[n]][mv]\n fr_to_br[n + 1] = Cache.fr_to_br_move[fr_to_br[n]][mv]\n parity[n + 1] = Cache.parity_move[parity[n]][mv]\n ur_to_df[n + 1] = Cache.ur_to_df_move[ur_to_df[n]][mv]\n\n min_dist_phase2[n + 1] = [\n Cache::BasePrune.get_pruning(\n Cache.slice_ur_to_df_parity_prune,\n (Cache::BaseCache::N_SLICE2 * ur_to_df[n + 1] + fr_to_br[n + 1]) * 2 + parity[n + 1]\n ),\n Cache::BasePrune.get_pruning(\n Cache.slice_urf_to_dlf_parity_prune,\n (Cache::BaseCache::N_SLICE2 * urf_to_dlf[n + 1] + fr_to_br[n + 1]) * 2 + parity[n + 1]\n )\n ].max\n\n break if min_dist_phase2[n + 1] == 0\n end\n\n depth_phase1 + depth_phase2\n end",
"def height\n if @root.nil?\n return 0\n elsif @root.left.nil? && @root.right.nil?\n return 1\n end\n return height_helper(@root)\n end",
"def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end",
"def current_depth\n current = Fiber.current\n managed_fiber?(current) ? current.depth : 0\n end",
"def depth(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n _pre_order(root, [], nil).first\n end",
"def get_depth(id)\n if id.nil?\n return 0\n end\n \n old_pairing = AssignmentPairing.find_by_assignment_id(id)\n if old_pairing.nil? \n return 0\n end\n\n old_pairing.depth + 1\n end",
"def depth\n @attributes[:depth]\n end",
"def height\n return 0 if @root.nil?\n current = @root\n height_recursive(current)\n end",
"def height\n return 0 if @root == nil\n\n current = @root\n\n return height_helper(current, 1, 1)\n end",
"def height\n return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def height\n # raise NotImplementedError\n # return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def depth_support(node)\n return 0 if node.nil?\n l_depth = depth_support(node.left)\n r_depth = depth_support(node.right)\n [l_depth, r_depth].max + 1\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def depth\n return 0 unless has_children?\n children.inject(0) {|dep,c| dep > c.depth ? dep : c.depth} + 1\n end",
"def height\n height_recursive(@root)\n end",
"def host_depth_divisor\n 1.0 / domain_depth_coef\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def depth_of(score)\n if include?(score) #This is calling the method on line 44\n 1 + @root_node.depth_of(score) \n else \n nil\n end \nend",
"def depth_of(score, current = @head, count = 0)\n if current.score == nil\n nil\n elsif current.score > score\n count += 1 \n depth_of(score, current.left, count)\n elsif\n current.score < score \n count += 1\n depth_of(score, current.right, count)\n else\n count\n end\n end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def height\n return height_helper(@root, 0, 1)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def test_depth_simple\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,200]\n end\n assert_equal(100, bbox.depth,\n 'Failed in test_depth_simple' )\n end",
"def test_depth=\n @br.depth = 100\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def depth=(_arg0); end",
"def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend",
"def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def bush_depth\n # タイルの場合、または最前面に表示フラグが ON の場合\n if @tile_id > 0 or @always_on_top\n return 0\n end\n # return 12 if @in_swamp #> Ajout des marais\n if @jump_count == 0 and $game_map.bush?(@x, @y)\n return 12\n else\n return 0\n end\n end",
"def height\n return @tree_height\n end",
"def depth\n PathExpression.range(path)[1]\n end",
"def depth\n children_depth + my_depth\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def depth\n return call_ancestry_method(:depth) if use_ancestry?\n\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rel.nil? ? 0 : rel.depth\n end",
"def depth\n @env.length\n end",
"def height\n return 0 if @root.nil?\n return [height_helper(@root.left), height_helper(@root.right)].max + 1\n end",
"def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end",
"def depth(sought_node, current_node = @root)\n # Base case we've reached beyond a leaf node.\n return -1 if current_node.nil?\n\n # Base case: We've reached the node.\n return 0 if current_node == sought_node\n\n # Otherwise, return the minimum of the depths\n 1 + [depth(sought_node, current_node.left), depth(sought_node, current_node.right)].max\n end",
"def height\n return height_helper(@root, 0)\n end",
"def height\n return height_helper(@root, 0)\n end",
"def depth(node, current = @root, count = 0)\n if current.eql?(node)\n return count\n elsif current.nil?\n return 0\n else\n count += 1\n count = [depth(node, current.left_node, count), depth(node, current.right_node, count)].max\n return count\n end\n end",
"def height\n @alive ? @height.round(1) : \"A dead tree is not very tall. :(\"\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def height\n @root and @root.height or 0\n end",
"def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end",
"def depth\n @options[:depth] += 1\n ret = yield\n @options[:depth] -= 1\n ret\n end",
"def height\n height_helper(@root, 0)\n end",
"def height_helper(current)\n num, left, right = 0, 0, 0\n return 0 if current.nil?\n left += height_helper(current.left)\n right += height_helper(current.right)\n num += 1 \n\n if left == right \n return num + right \n elsif left > right \n return num + left \n else \n return num + right \n end \n end",
"def height\n current_node = @root\n\n return height_helper(current_node)\n end",
"def height\n return 0 if @root.nil?\n return hegiht_helper(@root)\n end",
"def depth(node = root, parent = root, edges = 0)\n return 0 if node == parent\n return -1 if node.nil?\n\n if node < parent.data\n edges += 1\n depth(node, parent.left, edges)\n elsif node > parent.data\n edges += 1\n depth(node, parent.right, edges)\n else\n edges\n end\n end",
"def color_depth\n @iplimage_struct.depth\n end",
"def max_depth\n if @head.nil?\n return nil\n else\n max_depth = find_max_depth(head)\n end\n return max_depth\n end",
"def test_depth_of_root\n tree = BinarySearchTree.new\n tree.insert(13, \"Test1\")\n assert_equal tree.depth_of(13), 0\n end",
"def depth_of_index(link)\n self.avoid_zero_division(1, self.avoid_zero_division(self.depth_of_page_in_url(link), @dpus.values.max))\n end",
"def http_depth(default = DEPTH_INFINITY)\n # If its not set, we'll grab the default\n depth = @http_request.header('Depth')\n\n return default unless depth\n\n return DEPTH_INFINITY if depth == 'infinity'\n\n # If its an unknown value. we'll grab the default\n return default unless depth =~ /^[\\+\\-0-9\\.]$/ # TODO: valid replacement for ctype_digit?\n\n depth.to_i\n end",
"def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end",
"def update_depth\n if depth?\n self.update_attribute(:depth, level)\n end\n self\n end",
"def depth\n return codeArray.length\n end",
"def get_height_wid_recursion(node = root)\n if node.nil?\n return 0\n end\n ldepth = get_height_wid_recursion(node.left)\n rdepth = get_height_wid_recursion(node.right)\n depth = [ldepth, rdepth].max + 1\n return depth\n end",
"def height\n max_height = 0\n each do |child|\n if child.kind_of? Tree\n max_height = [max_height, 1].max\n else\n max_height = [max_height, child.height].max\n end\n end\n max_height.succ\n end",
"def depth\n crumbs.size\n end",
"def i_am_not_too_deep?(depth)\n depth <= @depth_to_explore\n end",
"def depth(d)\n @depth = d\n self\n end",
"def height\n return height_helper(@root)\n end",
"def trees_on_slope(right:, down:)\n x = 0\n y = 0\n count = 0\n loop do\n count += 1 if map(x, y) == \"#\"\n x += right\n y += down\n break if y >= @height\n end\n count\n end",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def calculate_query_depth\n query_depth = 0\n \n @object.vex_assignments.keys.select{ |a| a unless @object.vex_assignments[a].nil? or @object.vex_assignments[a][:through].nil? }.each do |key|\n query_depth = 1 if query_depth < 1\n eval = @object.vex_assignments[key][:through]\n if eval.is_a? Array\n eval.each do |through|\n unless @object.vex_assignments[through].nil? or @object.vex_assignments[through][:through].nil?\n query_depth = 2 if query_depth < 2\n test = @object.vex_assignments[through][:through]\n end\n end\n end\n end\n return query_depth\n end",
"def height_helper(current_node, level = 0)\n return level if !current_node\n level = [height_helper(current_node.left, level + 1), height_helper(current_node.right, level + 1)].max\n return level\n end",
"def find_height(root)\n return 0 if root.nil?\n left = find_height(root.left)\n right = find_height(root.right)\n left > right ? left + 1 : right + 1\nend",
"def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end",
"def depth(person)\n count = 0\n \n until person.ancestor == nil do\n person = person.ancestor\n count += 1\n end\n\n count\n end",
"def maximum_depth(node, depth = 0)\n @h = depth\n node.descendants.map{|d| @h = d.depth if d.depth >= @h }\n @h \nend",
"def height(level = 1)\n if @children[LEFT] != nil\n return @children[LEFT].height(level + 1)\n elsif @children[RIGHT] != nil\n return @children[RIGHT].height(level + 1)\n end\n end",
"def max_depth &blk\n xmax = 0\n loop do\n begin\n xmax = [xmax, yield].max\n rescue HaltState\n raise StopIteration\n end\n end\n xmax\n end"
] |
[
"0.72374964",
"0.6954031",
"0.68363124",
"0.6725244",
"0.6662514",
"0.66375756",
"0.65993387",
"0.6531998",
"0.6505338",
"0.6462455",
"0.6452357",
"0.6449738",
"0.6422739",
"0.640122",
"0.639568",
"0.63855505",
"0.6373602",
"0.6330523",
"0.63191706",
"0.6300117",
"0.6266125",
"0.62059563",
"0.61655223",
"0.6162594",
"0.6153291",
"0.61432415",
"0.61417574",
"0.61345726",
"0.61332697",
"0.61273",
"0.60940176",
"0.60641724",
"0.6051258",
"0.6045653",
"0.60411316",
"0.603116",
"0.6026356",
"0.6011139",
"0.60101545",
"0.60087365",
"0.6006177",
"0.59737355",
"0.5966187",
"0.59561574",
"0.59546614",
"0.5950769",
"0.5950769",
"0.5944834",
"0.59319097",
"0.5931892",
"0.5929522",
"0.5917029",
"0.5899362",
"0.58983856",
"0.58930814",
"0.58863103",
"0.5884877",
"0.5883057",
"0.58704495",
"0.5852298",
"0.5827803",
"0.5825346",
"0.58235955",
"0.58166033",
"0.581659",
"0.581659",
"0.57636553",
"0.5761808",
"0.5746346",
"0.57152814",
"0.571188",
"0.57104707",
"0.57069457",
"0.5699103",
"0.5695552",
"0.56880563",
"0.5681829",
"0.5663669",
"0.5650561",
"0.5648661",
"0.56481785",
"0.5647316",
"0.5646998",
"0.56460994",
"0.5633697",
"0.56199396",
"0.56195724",
"0.5619349",
"0.5607345",
"0.5585696",
"0.5584956",
"0.55749696",
"0.55644655",
"0.5562529",
"0.55611795",
"0.5538502",
"0.5524305",
"0.55187786",
"0.55128086",
"0.5510915",
"0.5505319"
] |
0.0
|
-1
|
Run the assertions for the deprecated depth method.
|
def do_deprecated_depth
assert_equal(1, @root.depth, "A single node's depth is 1")
@root << @child1
assert_equal(2, @root.depth, "This should be of depth 2")
@root << @child2
assert_equal(2, @root.depth, "This should be of depth 2")
@child2 << @child3
assert_equal(3, @root.depth, "This should be of depth 3")
assert_equal(2, @child2.depth, "This should be of depth 2")
@child3 << @child4
assert_equal(4, @root.depth, "This should be of depth 4")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_depth\n begin\n require 'structured_warnings'\n assert_warn(DeprecatedMethodWarning) { do_deprecated_depth }\n rescue LoadError\n # Since the structued_warnings package is not present, we revert to good old Kernel#warn behavior.\n do_deprecated_depth\n end\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def depth; end",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def depth()\n #This is a stub, used for indexing\n end",
"def test_depth_simple\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,200]\n end\n assert_equal(100, bbox.depth,\n 'Failed in test_depth_simple' )\n end",
"def depth=(_arg0); end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def get_depth\n raise \"Not implemented\"\n end",
"def update_depth\n if depth?\n self.update_attribute(:depth, level)\n end\n self\n end",
"def test_depth=\n @br.depth = 100\n end",
"def my_depth\n 1\n end",
"def assertions; end",
"def assertions; end",
"def i_am_not_too_deep?(depth)\n depth <= @depth_to_explore\n end",
"def depth\n depth_support(self.root)\n end",
"def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end",
"def validate\n if (depth != parent.depth+1)\n no(\"#{short} has bad depth\")\n end\n ui.puts \"#{indent}ok (depth: #{depth})#{short}\"\n end",
"def test_level\n assert_equal(0, @root.level, \"A root node's level is 0\")\n\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n\n setup_test_tree\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.level, \"Node #{child.name} should have level 1\")\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n end\n\n assert_equal(2, @child4.level, \"Child 4 should have level 2\")\n end",
"def depth=(depth)\n #This is a stub, used for indexing\n end",
"def depth_of(score)\n if include?(score) #This is calling the method on line 44\n 1 + @root_node.depth_of(score) \n else \n nil\n end \nend",
"def test_hack\n assert(true)\n end",
"def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def __assert__(pass, error=nil)\n Assertor.assert(pass, error, @negated, @backtrace)\n end",
"def current_depth\n 0\n end",
"def depth\n @options[:depth] += 1\n ret = yield\n @options[:depth] -= 1\n ret\n end",
"def with_depth_and_path\n with_depth && with_path\n end",
"def test_old_camelCase_method_names\n setup_test_tree\n\n meth_names_to_test = %w{isRoot? isLeaf? hasContent?\n hasChildren? setAsRoot! firstChild lastChild\n firstSibling isFirstSibling? lastSibling isLastSibling?\n isOnlyChild? nextSibling previousSibling nodeHeight nodeDepth\n createDumpRep removeFromParent! removeAll! freezeTree! }\n\n require 'structured_warnings'\n\n DeprecatedMethodWarning.disable do\n assert(@root.isRoot?) # Test if the original method is really called\n end\n\n meth_names_to_test.each do |meth_name|\n assert_warn(DeprecatedMethodWarning) {@root.send(meth_name)}\n end\n\n # Special Case for printTree to avoid putting stuff on the STDOUT during the unit test.\n begin\n require 'stringio'\n $stdout = StringIO.new\n assert_warn(DeprecatedMethodWarning) { @root.send('printTree') }\n ensure\n $stdout = STDOUT\n end\n\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def _validate_deprecated_in_favor_of(d)\n if spec.root.name == Specification.root_name(d)\n results.add_error('deprecated_in_favor_of', 'a spec cannot be ' \\\n 'deprecated in favor of itself')\n end\n end",
"def test_depth_zero\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,100]\n end\n assert_equal(0, bbox.depth,\n 'Failed in test_depth_zero' )\n end",
"def safe_level(*) end",
"def off_test_stack32_014\n rsp = exec(\": test 2 4 6 depth ;\")\n stk = stack(rsp)\n assert_equal([2, 4, 6, 3], stk)\n end",
"def depth(d)\n @depth = d\n self\n end",
"def deep_thaw!\n replace deep_thaw\n end",
"def assert_silent; end",
"def examine_context(ctx)\n exp, depth = *find_deepest_iterator(ctx)\n\n if depth && depth > value(MAX_ALLOWED_NESTING_KEY, ctx, DEFAULT_MAX_ALLOWED_NESTING)\n [SmellWarning.new(self,\n context: ctx.full_name,\n lines: [exp.line],\n message: \"contains iterators nested #{depth} deep\",\n parameters: { count: depth })]\n else\n []\n end\n # BUG: no longer reports nesting outside methods (eg. in Optparse)\n end",
"def assert(*args, &block)\n # to notice (and fail fast from) odd recursion problem\n raise \"Reentry bug while trying to assert(#{args.join(', ')})\" if (@_inside_wrong_assert ||= nil)\n @_inside_wrong_assert = true\n\n if block.nil?\n begin\n super(*args) # if there's a framework assert method (sans block), then call it\n rescue NoMethodError => e\n # note: we're not raising an AssertionFailedError because this is a programmer error, not a failed assertion\n raise \"You must pass a block to Wrong's assert and deny methods\"\n end\n else\n aver(:assert, *args, &block)\n end\n ensure\n @_inside_wrong_assert = false\n end",
"def assert(*args, &block)\n # to notice (and fail fast from) odd recursion problem\n raise \"Reentry bug while trying to assert(#{args.join(', ')})\" if @_inside_wrong_assert\n @_inside_wrong_assert = true\n\n if block.nil?\n begin\n super(*args) # if there's a framework assert method (sans block), then call it\n rescue NoMethodError => e\n # note: we're not raising an AssertionFailedError because this is a programmer error, not a failed assertion\n raise \"You must pass a block to Wrong's assert and deny methods\"\n end\n else\n aver(:assert, *args, &block)\n end\n ensure\n @_inside_wrong_assert = false\n end",
"def test_old_camelCase_method_names\n @left_child2 = Tree::BinaryTreeNode.new(\"A Child at Left\", \"Child Node @ left\")\n @right_child2 = Tree::BinaryTreeNode.new(\"B Child at Right\", \"Child Node @ right\")\n\n require 'structured_warnings'\n\n meth_names_for_test = %w{leftChild isLeftChild? rightChild isRightChild?}\n\n meth_names_for_test.each do |meth_name|\n assert_warn(DeprecatedMethodWarning) {@root.send(meth_name)}\n end\n\n assert_warn(DeprecatedMethodWarning) {@root.leftChild = @left_child2}\n assert_warn(DeprecatedMethodWarning) {@root.rightChild = @right_child2}\n\n end",
"def sniff\n find_violations.group_by(&:depth).map do |depth, group|\n lines = group.map(&:line)\n smell_warning(\n lines: lines,\n message: \"contains iterators nested #{depth} deep\",\n parameters: { depth: depth })\n end\n end",
"def at_depth(depth)\n where \"NLEVEL(#{table_name}.#{ltree_path_column}) = ?\", depth\n end",
"def too_deep?( depth )\n depth.to_i > 0 && (depth + 1) <= path.to_s.count( '/' )\n end",
"def assert_missing_delimitation!\n end",
"def apply_depth(depth)\n @min_depth = depth if depth < @min_depth\n end",
"def test_dead_cell_with_three_neighbors_lives\n assert @life.will_live?(false, 3)\n end",
"def test_depth_of_root\n tree = BinarySearchTree.new\n tree.insert(13, \"Test1\")\n assert_equal tree.depth_of(13), 0\n end",
"def depth\n @traversal_position.depth\n end",
"def check_integrity(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"stray node found in level: #{l} which is #{list.to_a(nil,nil,nil,l)}\" if !difference.empty? \n expect(difference).to match_array([])\n end\nend",
"def depth(options)\n request :public, :get, :depth, options\n end",
"def test(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"test failed level #{l} ,inconsistent node(s) #{difference}\" if (difference.count != 0)\n end\n puts \"test complete\"\nend",
"def scope_depth depth_options, depth\n depth_options.inject(self.base_class) do |scope, option|\n scope_name, relative_depth = option\n if [:before_depth, :to_depth, :at_depth, :from_depth, :after_depth].include? scope_name\n scope.send scope_name, depth + relative_depth\n else\n raise Ancestry::AncestryException.new(\"Unknown depth option: #{scope_name}.\")\n end\n end\n end",
"def rebuild_depth_cache!\n raise Ancestry::AncestryException.new(I18n.t(\"ancestry.cannot_rebuild_depth_cache\")) unless respond_to? :depth_cache_column\n\n ancestry_base_class.transaction do\n unscoped_where do |scope|\n scope.find_each do |node|\n node.update_attribute depth_cache_column, node.depth\n end\n end\n end\n end",
"def test_print_classes_negative\n\t\tassert_raises(\"Cannot have fewer than 0 classes\") { print_classes(-1,-1) }\n\tend",
"def partial_book_depth(symbol:, level:, methods:)\n ws_single(\n stream: {\n symbol: symbol,\n type: 'depth',\n level: level,\n },\n methods: methods,\n )\n end",
"def assert_test_warnings\n assert has_test_warnings?(@review)\n end",
"def test_for_not_cathedral\n testLocation = LocationNode.new(\"Hillman\",nil,nil,nil,nil)\n assert_equal false, incrementClass(testLocation)\n end",
"def assertions=(_arg0); end",
"def assertions=(_arg0); end",
"def scope_depth depth_options, depth\n depth_options.inject(ancestry_base_class) do |scope, option|\n scope_name, relative_depth = option\n if [:before_depth, :to_depth, :at_depth, :from_depth, :after_depth].include? scope_name\n scope.send scope_name, depth + relative_depth\n else\n raise Ancestry::AncestryException.new(I18n.t(\"ancestry.unknown_depth_option\", scope_name: scope_name))\n end\n end\n end",
"def check_syntax_trace(context, schema, datum, depth, trace)\n return unless trace < 0\n depth.times { print \"*\" }\n print \"* #{context}\\n schema: #{schema.inspect[0 .. trace.abs]}\\n\"\n print \" datum: #{datum.inspect[0 .. trace.abs]}\\n\"\n end",
"def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end",
"def trace_possibility\n gen_tree if @json_tree_type == 'flat_tree'\n\n @json_tree.each do |k, v|\n v['possibility'] = trace_possibility2(v)\n end\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def depth\n self[:depth]\n end",
"def issue_deprecations\n Pkg::Params::DEPRECATIONS.each do |v|\n if self.instance_variable_get(\"@#{v[:var]}\")\n warn v[:message]\n end\n end\n end",
"def eval_depth(name)\n depth = (name.length - name.lstrip.length) / 3 + 2\n if depth < @dir.length\n (@dir.length - depth).times {@dir.pop}\n end\n end",
"def assert!(*arguments, &block)\n options = (Hash === arguments.last ? arguments.pop : {})\n\n backtrace = options[:backtrace] || caller\n message = options[:message] || assert_message(*arguments, &block)\n\n pass = pass?(*arguments, &block)\n\n assert pass, self, message, backtrace\n\n #if pass?(*arguments, &block)\n # increment(:pass)\n #else\n # increment(:fail)\n # fail self, message, backtrace\n #end\n end",
"def examine_context(ctx)\n exp, depth = *find_deepest_iterator(ctx)\n\n if depth && depth > value(MAX_ALLOWED_NESTING_KEY, ctx, DEFAULT_MAX_ALLOWED_NESTING)\n smell = SmellWarning.new(SMELL_CLASS, ctx.full_name, [exp.line],\n \"contains iterators nested #{depth} deep\",\n @source, SMELL_SUBCLASS,\n {NESTING_DEPTH_KEY => depth})\n [smell]\n else\n []\n end\n # BUG: no longer reports nesting outside methods (eg. in Optparse)\n end",
"def test_leaving_first_3_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 0\n\tp.silver_found = 0\n\tp.num_loc_visited = 3\n\tassert p.leaving?\n end",
"def rebuild_depth_cache!\n raise Ancestry::AncestryException.new(\"Cannot rebuild depth cache for model without depth caching.\") unless respond_to? :depth_cache_column\n self.base_class.all.each do |node|\n node.update_attribute depth_cache_column, node.depth\n end\n end",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def assert_(diagnostic = nil, twizzler = '_', &block)\n # puts reflect(&block) # activate this line and test to see all your successes!\n result = nil\n \n begin\n\tresult = block.call\n rescue => e\n diagnostic = [diagnostic, e.inspect, *e.backtrace].compact.join(\"\\n\\t\")\n _flunk_2_0(\"\\nassert#{ twizzler }{ \", diagnostic, block, result)\n end\n \n add_assertion and return if result\n _flunk_2_0(\"assert#{ twizzler }{ \", diagnostic, block, result)\n end",
"def test_leaving_last_2_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 1\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\tassert p.leaving?\n end",
"def raise_ruby_19_deprecation_warning!\n return unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')\n\n require 'ddtrace/patcher'\n\n Datadog::Patcher.do_once(:ruby_19_deprecation_warning) do\n Datadog::Tracer.log.warn(RUBY_19_DEPRECATION_WARNING)\n end\n end",
"def instance_dependency(opts)\n opts = check_params(opts,[:depth])\n super(opts)\n end",
"def assertions\n @@assertions\n end",
"def raise_deprecations; end",
"def assert_not_deprecated(deprecator = nil, &block)\n result, deprecations = collect_deprecations(deprecator, &block)\n assert deprecations.empty?, \"Expected no deprecation warning within the block but received #{deprecations.size}: \\n #{deprecations * \"\\n \"}\"\n result\n end",
"def safe_test(options = {})\n # JRuby and Rubinius us don't support SAFE levels.\n available = !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE))\n\n if available || options[:unavailable] != :skip\n thread = Thread.new do\n orig_diff = Minitest::Assertions.diff\n\n $SAFE = options[:level] || 1 if available\n\n # Disable the use of external diff tools during safe mode tests (since\n # safe mode will prevent their use). The initial value is retrieved\n # before activating safe mode because the first time\n # Minitest::Assertions.diff is called, it will attempt to find a diff\n # tool. Finding the diff tool will also fail in safe mode.\n Minitest::Assertions.diff = nil\n begin\n yield\n ensure\n Minitest::Assertions.diff = orig_diff\n end\n end\n\n thread.join\n end\n end",
"def print(depth)\n spaces = \" \".freeze * depth\n \"#{left_stats} #{spaces} └── #{@node.name}\"\n end",
"def verifier_level\n 6\n end",
"def test_truth\n assert nodes(:draft_1)\n end",
"def assert _args\n \"assert _args;\" \n end",
"def flunk(msg=nil)\n __assert__(false, msg)\n end",
"def lvlres\n @level = 0\n lvlup\n end",
"def test_draw_included_in_stack\n assert_equal (draw - stack), []\n end",
"def assert(*args, &block)\n if block.nil?\n begin\n super\n rescue NoMethodError => e\n # note: we're not raising an AssertionFailedError because this is a programmer error, not a failed assertion\n raise \"You must pass a block to Wrong's assert and deny methods\"\n end\n else\n aver(:assert, *args, &block)\n end\n end",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def testInitialize_2SW_1NE_depth2\n ps = [UniquePoint3.new(0,0,0), UniquePoint3.new(3,3,0), UniquePoint3.new(8,8,8)]\n q = QuadTreeAccelerator.new(ps)\n assert_equal(\n\"(0,[[0,0,0],[8,8,8]],[])\n SW\n (1,[[0,0,0],[4.0,4.0,8]],[])\n SW\n (2,[[0,0,0],[2.0,2.0,8]],[[0,0,0]])\n NE\n (2,[[2.0,2.0,0],[4.0,4.0,8]],[[3,3,0]])\n NE\n (1,[[4.0,4.0,0],[8,8,8]],[[8,8,8]])\n\", q.to_s)\n end",
"def find_level_dependencies_graph\n long_distance_dependents = Array.new\n @lvl_deps = @dd_deps.deep_clone\n @levels.sort.reverse.each do |pair|\n level, components = pair\n components.each do |component|\n long_distance_dependents.clear\n @dd_deps[component].each do |dependent|\n long_distance_dependents << dependent if level_of(dependent) < level-1\n end\n @lvl_deps[component] -= long_distance_dependents\n end\n end\n end",
"def init_simple_tree\n @root_org = Org.create(name: 'root')\n @lv1_child_org = Org.create(name: 'lv1')\n @lv1_child_org2 = Org.create(name: 'lv1-2')\n @lv2_child_org = Org.create(name: 'lv2')\n @lv2_child_org2 = Org.create(name: 'lv2-2')\n @lv2_child_org3 = Org.create(name: 'lv2-3')\n @lv2_child_org4 = Org.create(name: 'lv2-4')\n @lv3_child_org = Org.create(name: 'lv3')\n @lv3_child_org2 = Org.create(name: 'lv3-2')\n @lv4_child_org = Org.create(name: 'lv4')\n @lv4_child_org2 = Org.create(name: 'lv4-2')\n @lv5_child_org = Org.create(name: 'lv5')\n @lv5_child_org2 = Org.create(name: 'lv5-2')\n\n current_time = Time.now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @root_org.id,\n distance: 0,\n start_time: 10.minutes.ago(current_time),\n end_time: 1000.years.from_now,\n scope_name: 'default'\n )\n\n # 10 minutes ago\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 2,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n # now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org3.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org3.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org4.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org4.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv3_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org2.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\nend",
"def test_should_block_recursion_in_tree\n group = Group.find @greeks_group.id\n\n assert_raises(RecursionInTree) { group.parent = Group.find @cretes_group.id }\n end",
"def state_depth_must_be(level)\n states[0..level].each do |a|\n raise 'factory state error' if a.nil?\n end\n end",
"def assert\n raise \"Assertion failed !\" unless yield # if $DEBUG\nend",
"def warn_for_deprecations\n deprecated_pods = root_specs.select do |spec|\n spec.deprecated || spec.deprecated_in_favor_of\n end\n deprecated_pods.each do |spec|\n if spec.deprecated_in_favor_of\n UI.warn \"#{spec.name} has been deprecated in \" \\\n \"favor of #{spec.deprecated_in_favor_of}\"\n else\n UI.warn \"#{spec.name} has been deprecated\"\n end\n end\n end",
"def test_ut_t2_ars_ard_001\n assert_equal [1,2,3],AnalyzeRuleConfigDetail.levels\n end",
"def test_slide_1\n TaxonName.slide(2, 3)\n assert_equal 6, @child_middle.reload.l\n TaxonName.slide(-2, 3)\n assert @root_node.reload.check_subtree\n end",
"def calculate_query_depth\n query_depth = 0\n \n @object.vex_assignments.keys.select{ |a| a unless @object.vex_assignments[a].nil? or @object.vex_assignments[a][:through].nil? }.each do |key|\n query_depth = 1 if query_depth < 1\n eval = @object.vex_assignments[key][:through]\n if eval.is_a? Array\n eval.each do |through|\n unless @object.vex_assignments[through].nil? or @object.vex_assignments[through][:through].nil?\n query_depth = 2 if query_depth < 2\n test = @object.vex_assignments[through][:through]\n end\n end\n end\n end\n return query_depth\n end"
] |
[
"0.77921015",
"0.55722946",
"0.5520603",
"0.54864395",
"0.5477407",
"0.5471653",
"0.54617983",
"0.5444409",
"0.54002744",
"0.5350991",
"0.5350007",
"0.53381425",
"0.5314139",
"0.5314139",
"0.52814263",
"0.5274706",
"0.5245313",
"0.5232082",
"0.5204234",
"0.5113039",
"0.5080118",
"0.5046351",
"0.50322163",
"0.50135076",
"0.49915782",
"0.49879083",
"0.49855372",
"0.49695173",
"0.49690086",
"0.4958365",
"0.49307242",
"0.49029392",
"0.4892494",
"0.4888615",
"0.4887163",
"0.48793933",
"0.48618808",
"0.48506498",
"0.48470572",
"0.4840288",
"0.48281747",
"0.4820303",
"0.48055053",
"0.47917515",
"0.47812214",
"0.47616106",
"0.47582173",
"0.47537953",
"0.47457406",
"0.47413257",
"0.4736461",
"0.47328085",
"0.4729428",
"0.47291481",
"0.4723943",
"0.47228652",
"0.4708231",
"0.46963784",
"0.46915555",
"0.46915555",
"0.46823958",
"0.46794444",
"0.4677236",
"0.46707204",
"0.46703908",
"0.46646714",
"0.4662011",
"0.46609265",
"0.46602297",
"0.46558782",
"0.46515754",
"0.46280655",
"0.46252778",
"0.46235025",
"0.4618787",
"0.46135136",
"0.46109024",
"0.46107477",
"0.46104574",
"0.46048826",
"0.46016788",
"0.4597841",
"0.45723838",
"0.45708922",
"0.4563742",
"0.45614234",
"0.45488235",
"0.45460328",
"0.45289516",
"0.45196262",
"0.45187774",
"0.45157233",
"0.45143673",
"0.45043936",
"0.4503017",
"0.45013723",
"0.4487763",
"0.44874275",
"0.44698834",
"0.44698367"
] |
0.72621274
|
1
|
Test the height computation algorithm
|
def test_node_height
assert_equal(0, @root.node_height, "A single node's height is 0")
@root << @child1
assert_equal(1, @root.node_height, "This should be of height 1")
assert_equal(0, @child1.node_height, "This should be of height 0")
@root << @child2
assert_equal(1, @root.node_height, "This should be of height 1")
assert_equal(0, @child2.node_height, "This should be of height 0")
@child2 << @child3
assert_equal(2, @root.node_height, "This should be of height 2")
assert_equal(1, @child2.node_height, "This should be of height 1")
assert_equal(0, @child3.node_height, "This should be of height 0")
@child3 << @child4
assert_equal(3, @root.node_height, "This should be of height 3")
assert_equal(2, @child2.node_height, "This should be of height 2")
assert_equal(1, @child3.node_height, "This should be of height 1")
assert_equal(0, @child4.node_height, "This should be of height 0")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def height(input)\n process(:height, input)\n end",
"def height\n return 0 if @root.nil?\n return hegiht_helper(@root)\n end",
"def get_height(*params); raise('Stub or mock required.') end",
"def height!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 36 )\n\n type = HEIGHT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 366:9: 'height'\n match( \"height\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 36 )\n\n end",
"def height(_hash)\n raise Sibit::NotSupportedError, 'Earn API doesn\\'t provide height()'\n end",
"def height(_hash)\n raise Sibit::NotSupportedError, 'Blockchair API doesn\\'t provide height()'\n end",
"def terrain_height\n end",
"def height\n @alive ? @height.round(1) : \"A dead tree is not very tall. :(\"\n end",
"def height\n features.intersection(Features::HEIGHT)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def height; end",
"def height; end",
"def height\n heights = [left_height, right_height].sort\n\n heights.last\n end",
"def update_heights\n\t\t@height = @tile.attributes[\"height\"]\n\t\t@waterlevel = @tile.agents.length * HEIGHT_MOD \n\tend",
"def height\n end",
"def height\n end",
"def height\r\n assert_exists\r\n return @o.invoke(\"height\").to_s\r\n end",
"def height(hash)\n best_of('height') do |api|\n api.height(hash)\n end\n end",
"def height\n height_helper(@root, 0)\n end",
"def height\n return height_helper(@root)\n end",
"def test_density\n game=GameOfLife.new(3,3,100)\n assert_equal 9,weigh_universe(game.state)\n\n game.populate(3,3,0)\n assert_equal 0,weigh_universe(game.state)\n\n # This test will fail just through randomness 2 in 2^100 times\n game.populate(10,10,50)\n weight=weigh_universe(game.state)\n assert weight<100\n assert weight>0\n end",
"def height\n return height_helper(@root, 0)\n end",
"def height\n return height_helper(@root, 0)\n end",
"def height(current = @root, array)\n\n end",
"def height\n # raise NotImplementedError\n # return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def eddie_izzards_height (heel_height=0)\n 67 + heel_height\n end",
"def height\n return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end",
"def height\n height_recursive(@root)\n end",
"def height()\n 0\n end",
"def height\n @y1 - @y0\n end",
"def height\n puts \"Height: #{@tHeight} meter(s).\"\n # puts \"Fruits: #{@fruits} Fruit(s).\"\n oneYearPasses\n end",
"def height\n return 0 if @root == nil\n\n current = @root\n\n return height_helper(current, 1, 1)\n end",
"def height\n memoized_info[:height]\n end",
"def height\n return 0 if @root == nil\n return 1 if @root && (@root.left == nil && @root.right == nil)\n height_helper(@root, 0)\n end",
"def test_height_simple\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,200]\n end\n assert_equal(100, bbox.height,\n 'Failed in test_height_simple' )\n end",
"def deltaHeight( x1, y1, x2, y2 )\n # Translate the physical location to image pixel coordinates\n if( $FlipX ) then\n px1 = ($ImageOffsetX + ( $BlockX - x2 ) * $aspect).to_i\n px2 = ($ImageOffsetX + ( $BlockX - x1 ) * $aspect).to_i\n else\n px1 = ($ImageOffsetX + x1 * $aspect).to_i\n px2 = ($ImageOffsetX + x2 * $aspect).to_i\n end\n if( $FlipY ) then\n py1 = ($ImageOffsetY + ( $BlockX - y2 ) * $aspect).to_i\n py2 = ($ImageOffsetY + ( $BlockX - y1 ) * $aspect).to_i\n else\n py1 = ($ImageOffsetY + y1 * $aspect).to_i\n py2 = ($ImageOffsetY + y2 * $aspect).to_i\n end\n\n # Check we're inside the image\n if( px2 >= $ImageX ) then px2 = $ImageX - 1 end\n if( py2 >= $ImageY ) then py2 = $ImageY - 1 end\n if( px1 < 0 ) then px1 = 0 end\n if( py1 < 0 ) then py1 = 0 end\n\n min = $maxRed\n max = $minRed\n rangeX = (px1..px2)\n rangeY = (py1..py2)\n rangeX.each do |x|\n rangeY.each do |y|\n red = pixelValue($png[x, y])\n if red > max then max = red end\n if red < min then min = red end\n end\n end\n max - min\nend",
"def height=(_); end",
"def height=(_); end",
"def height\n @height = @height + 1\n end",
"def max_area_brute(heights)\n max_area = 0\n\n (0..heights.length - 1).each do |i|\n ((i + 1)..heights.length - 1).each do |j|\n min_height = [heights[i], heights[j]].min\n\n local_area = min_height * (j - i)\n max_area = [max_area, local_area].max\n end\n end\n\n max_area\nend",
"def height_multiplier\n @height_multiplier || 1\n end",
"def height\n return 0 if @root.nil?\n current = @root\n height_recursive(current)\n end",
"def eddie_izzards_height(heel_height = 0)\n\t67 + heel_height\nend",
"def eddie_izzards_height(heelHeight=0)\n heelHeight + 67\nend",
"def height(y = @y)\n height = [y]\n return height unless @page\n @page.size[2].times { |i| height << y - (i + 1) }\n @page.size[3].times { |i| height << y + (i + 1) }\n return height\n end",
"def height\n defined?(@ht) ? @ht : nil\n end",
"def height\n @bottom_edge - @top_edge\n end",
"def height\n current_node = @root\n\n return height_helper(current_node)\n end",
"def height\n TILE_BASE_HEIGHT\n end",
"def height\n top - bottom\n end",
"def height(hash)\n json = Sibit::Json.new(http: @http, log: @log).get(\n Iri.new('https://chain.api.btc.com/v3/block').append(hash)\n )\n data = json['data']\n raise Sibit::Error, \"The block #{hash} not found\" if data.nil?\n h = data['height']\n raise Sibit::Error, \"The block #{hash} found but the height is absent\" if h.nil?\n @log.info(\"The height of #{hash} is #{h}\")\n h\n end",
"def height\n dimensions()[:y]\n end",
"def calculate_h\n # Get all black and red cells and calculate the distance from the last cell or the first cell\n h = 0\n @state.each_with_index do |cell, index|\n if cell != 'F'\n h += (cell == 'B') ? @state.length - index : index\n end\n end\n return h\n end",
"def height(latitude, longitude)\n get_lookup(:height).search(latitude, longitude)\n end",
"def height\n @rows * @block_size\n end",
"def pixelheight\n end",
"def height\n array.size\n end",
"def height\r\n return (@y2-@y1).abs\r\n end",
"def eddie_izzards_height(height_of_heels=0)\n new_height = height_of_heels + 67\n return new_height\n end",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def max_area(height)\n max_area = 0\n seen = {}\n\n (0...height.length).each do |idx|\n next if seen[idx]\n seen[idx] = true\n\n (idx + 1...height.length).each do |idx2|\n h = [height[idx], height[idx2]].min\n area = h * (idx2 - idx)\n max_area = area > max_area ? area : max_area\n end\n end\n \n max_area\nend",
"def height_edges(root)\n return -1 if root == nil\n\n left = height_edges(root.left)\n right = height_edges(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height\n max_height = 0\n each do |child|\n if child.kind_of? Tree\n max_height = [max_height, 1].max\n else\n max_height = [max_height, child.height].max\n end\n end\n max_height.succ\n end",
"def get_height\n return get_keyword_value(\"FLOOR-HEIGHT\").to_f\n end",
"def height(other)\n a = distance_to_chord(other)\n Math.sqrt(r ** 2 - a ** 2)\n end",
"def height\n if @root.nil?\n return 0\n elsif @root.left.nil? && @root.right.nil?\n return 1\n end\n return height_helper(@root)\n end",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def height\n @dimensions.y\n end",
"def height(node)\n return 0 if node.nil?\n\n lh = height(node.left)\n rh = height(node.right)\n @ans = [@ans, lh + rh].max\n 1 + [lh, rh].max\nend",
"def g_height \n Config.ground_height\n end",
"def height_checker(heights)\n sorted = heights.sort\n count = 0\n (0...heights.length).each do |i|\n count += 1 if heights[i] != sorted[i]\n end \n count\nend",
"def height\n @height\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def valid_height?(h)\n unit = h.chars.last(2).join('')\n value = h.chars.first(3).join('').to_i\n\n if unit == 'cm'\n value >=150 && value <= 193\n elsif unit == 'in'\n value >= 59 && value <= 76\n else\n false\n end\n end",
"def calculate_hyperballs\n while hyperball_once\n @ball_size += 1\n end\n\n print_centralities\n end",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def eddie_izzards_height(heels_height=0)\n heels_height+67\nend",
"def tip_height(state)\n\t\tt1 = state[0][0]\n\t\tt2 = state[1][0]\n\n\t\tL1 * -cos(t1) + L2 * -cos(t1 + t2)\n\tend",
"def height\n return 0 if @root.nil?\n return [height_helper(@root.left), height_helper(@root.right)].max + 1\n end",
"def height_helper(current)\n num, left, right = 0, 0, 0\n return 0 if current.nil?\n left += height_helper(current.left)\n right += height_helper(current.right)\n num += 1 \n\n if left == right \n return num + right \n elsif left > right \n return num + left \n else \n return num + right \n end \n end",
"def max_area(height)\r\n max_area = 0\r\n height.each_with_index do |start, idx1|\r\n height.each_with_index do |finish, idx2|\r\n if idx2 > idx1\r\n area = [start, finish].min * (idx2 - idx1) \r\n max_area = area if area > max_area\r\n end\r\n end\r\n end\r\n max_area\r\nend",
"def eddie_izzards_height(heel_height = 0)\n heel_height + 67\nend",
"def find_height_edges(root)\n return -1 if root == nil\n left_height = 1 + find_height_edges(root.left)\n right_height = 1 + find_height_edges(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def height_calc\n lines = [@data.length, page_row_max].min rescue page_row_max\n return lines * line_height + standard_padding * 2\n end",
"def height_calc\n lines = [@data.length, page_row_max].min rescue page_row_max\n return lines * line_height + standard_padding * 2\n end",
"def eddie_izzards_height (heels=0)\n 67 + heels\nend",
"def height\n assert_exists\n driver.execute_script \"return arguments[0].height\", @element\n end",
"def height\n return @tree_height\n end",
"def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def pyramid_height(cost, total)\n cans = total / cost\n i = 0\n sum = 0\n while sum + (i+1)**2 <= cans\n i += 1\n sum += i**2\n end\n i\nend",
"def do_stuff1(arr)\n # d0 Heights array to store heights\n heights = []\n # d1 Iterate from last element of input array down to first element\n (arr.size - 1).downto(0).each do |i|\n # d2 push each height by running find_height with arr and current i as arguments\n heights.push(find_height(arr,i))\n end\n # puts heights[-1]\n print heights[-1]\n puts \"\\n\"\nend",
"def check_height(node)\n return 0 if node.nil?\n\n leftHeight = check_height(node.left)\n return -1 if leftHeight == -1\n\n rightHeight = check_height(node.right)\n return -1 if rightHeight == -1\n\n diff = leftHeight - rightHeight\n height = nil\n\n if diff.abs > 1\n height = -1\n else\n height = [leftHeight, rightHeight].max + 1\n end\n\n height\n end",
"def initialize(heights)\r\n\t\t@heights = heights\r\n\t\t@length = heights.length\r\n\t\t@max = {indexes: [0,0], area: 0}\r\n\t\tfind_max_area\r\n\tend",
"def maxArea(height)\n max = 0\n i = 0\n j = height.length - 1\n while i < j\n if height[i] < height[j]\n tmp = height[i] * (j - i)\n i += 1\n else\n tmp = height[j] * (j - i)\n j -= 1\n end\n if tmp > max\n max = tmp\n end\n end\n return max\nend",
"def height\n top + bottom\n end",
"def height(current = @root, h = 0)\n return h unless current\n\n height_left = height(current.left, h + 1)\n height_right = height(current.right, h + 1)\n\n height_left > height_right ? height_left : height_right\n end",
"def base_height; 24; end",
"def base_height; 24; end"
] |
[
"0.6804894",
"0.66909003",
"0.66903865",
"0.66596335",
"0.6650588",
"0.66208225",
"0.6558609",
"0.6541876",
"0.65319586",
"0.649235",
"0.649235",
"0.6458327",
"0.6458327",
"0.64481395",
"0.6440195",
"0.64302826",
"0.64302826",
"0.6368589",
"0.6316633",
"0.6289489",
"0.6283935",
"0.62673765",
"0.6263931",
"0.6263931",
"0.6259942",
"0.62533885",
"0.625273",
"0.6239975",
"0.62150854",
"0.6156898",
"0.6137548",
"0.61372125",
"0.61253965",
"0.61173517",
"0.6080497",
"0.60756284",
"0.60538435",
"0.6051648",
"0.6041771",
"0.6041771",
"0.6038308",
"0.6028613",
"0.60076433",
"0.6006554",
"0.5988107",
"0.59807473",
"0.5973626",
"0.5964867",
"0.5960356",
"0.59589654",
"0.5955369",
"0.59552824",
"0.5951246",
"0.5950772",
"0.5934258",
"0.5918624",
"0.5892681",
"0.5892574",
"0.5890905",
"0.58884",
"0.5869986",
"0.585205",
"0.5842167",
"0.58389145",
"0.58264637",
"0.58244455",
"0.5816948",
"0.58093506",
"0.5805254",
"0.57952607",
"0.579451",
"0.5784153",
"0.5782013",
"0.5781106",
"0.57808083",
"0.57790715",
"0.57654953",
"0.57636636",
"0.5761225",
"0.5751722",
"0.57418406",
"0.5733429",
"0.5726139",
"0.57230765",
"0.5710636",
"0.5708659",
"0.5708659",
"0.56812435",
"0.5680973",
"0.5677928",
"0.5674774",
"0.56667095",
"0.56642723",
"0.56628627",
"0.5660775",
"0.56579727",
"0.5656285",
"0.56558526",
"0.56538206",
"0.56538206"
] |
0.6244528
|
27
|
Test the depth computation algorithm. Note that this is the correct depth computation. The original Tree::TreeNodedepth was incorrectly computing the height of the node instead of its depth.
|
def test_node_depth
assert_equal(0, @root.node_depth, "A root node's depth is 0")
setup_test_tree
for child in [@child1, @child2, @child3]
assert_equal(1, child.node_depth, "Node #{child.name} should have depth 1")
end
assert_equal(2, @child4.node_depth, "Child 4 should have depth 2")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end",
"def test_depth_of_root\n tree = BinarySearchTree.new\n tree.insert(13, \"Test1\")\n assert_equal tree.depth_of(13), 0\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end",
"def depth\n @traversal_position.depth\n end",
"def get_depth\n raise \"Not implemented\"\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def depth\n n = 0\n p, q = lftp, lftq\n while p != 0\n x = p.inverse(q)\n p, q = (x * p - 1) / q, x\n n += 1\n end\n n\n end",
"def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def depth(value)\n node = find(value)\n find_depth(node)\n end",
"def do_deprecated_depth\n assert_equal(1, @root.depth, \"A single node's depth is 1\")\n\n @root << @child1\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @root << @child2\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @child2 << @child3\n assert_equal(3, @root.depth, \"This should be of depth 3\")\n assert_equal(2, @child2.depth, \"This should be of depth 2\")\n\n @child3 << @child4\n assert_equal(4, @root.depth, \"This should be of depth 4\")\n end",
"def depth(node = root, parent = root, edges = 0)\n return 0 if node == parent\n return -1 if node.nil?\n\n if node < parent.data\n edges += 1\n depth(node, parent.left, edges)\n elsif node > parent.data\n edges += 1\n depth(node, parent.right, edges)\n else\n edges\n end\n end",
"def depth\n depth_support(self.root)\n end",
"def test_total_depth\n @t1 = @trees[\"((A,B),(C,D));\"]\n foo = parse_tree(@t1) # gets the root @node\n\n assert_equal 3, total_depth(foo, 0)\n\n @t2 = @trees[\"((raccoon:19.19959,bear:6.80041):0.84600,\n ((sea_lion:11.99700, seal:12.00300):7.52973, \n ((monkey:100.85930,cat:47.14069):20.59201,weasel:18.87953):2.09460):3.87382,dog:25.46154);\"]\n bar = parse_tree(@t2)\n\n assert_equal 6, total_depth(bar, 0)\n\n blorf = parse_tree(\"(A,B,C)\")\n assert_equal 1, total_depth(blorf,0)\n\n blorf2 = parse_tree(\"((A,B),(C,D),(E,F))\")\n assert_equal 4, total_depth(blorf2,0) \n end",
"def depth()\n #This is a stub, used for indexing\n end",
"def test_depth_simple\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,200]\n end\n assert_equal(100, bbox.depth,\n 'Failed in test_depth_simple' )\n end",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def depth(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n _pre_order(root, [], nil).first\n end",
"def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def node_depths(root, depth = 0)\n if root.nil?\n return 0\n end\n\n return depth + node_depths(root.left, depth + 1) + node_depths(root.right, depth + 1)\nend",
"def depth_support(node)\n return 0 if node.nil?\n l_depth = depth_support(node.left)\n r_depth = depth_support(node.right)\n [l_depth, r_depth].max + 1\n end",
"def depth\n return call_ancestry_method(:depth) if use_ancestry?\n\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rel.nil? ? 0 : rel.depth\n end",
"def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end",
"def depth_max; depths.max end",
"def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end",
"def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end",
"def depth\n return 0 unless has_children?\n children.inject(0) {|dep,c| dep > c.depth ? dep : c.depth} + 1\n end",
"def test_insert_root_node_returns_depth\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n assert_equal 0, tree.root.depth\n end",
"def test_insert_second_node_returns_depth\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n assert_equal 1, tree.root.left_node.depth\n end",
"def depth\n children_depth + my_depth\n end",
"def depth(sought_node, current_node = @root)\n # Base case we've reached beyond a leaf node.\n return -1 if current_node.nil?\n\n # Base case: We've reached the node.\n return 0 if current_node == sought_node\n\n # Otherwise, return the minimum of the depths\n 1 + [depth(sought_node, current_node.left), depth(sought_node, current_node.right)].max\n end",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def depth_of(score)\n if @head.score == score\n #depth at head is nil, this conditional assigns a zero\n #value to the head\n if @head.depth == nil\n 0\n else\n @head.depth\n end\n else\n #searches tree for node with inputted score\n if score < @head.score && @head.left_link != nil\n @head = @head.left_link\n depth_of(score)\n elsif score > @head.score && @head.right_link != nil\n @head = @head.right_link\n depth_of(score)\n end\n end\n end",
"def depth\n self[:depth]\n end",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend",
"def depth_of(score, current = @head, count = 0)\n if current.score == nil\n nil\n elsif current.score > score\n count += 1 \n depth_of(score, current.left, count)\n elsif\n current.score < score \n count += 1\n depth_of(score, current.right, count)\n else\n count\n end\n end",
"def depth(node, current = @root, count = 0)\n if current.eql?(node)\n return count\n elsif current.nil?\n return 0\n else\n count += 1\n count = [depth(node, current.left_node, count), depth(node, current.right_node, count)].max\n return count\n end\n end",
"def depth_of(score)\n return 0 if self.root.score == score\n if score > self.root.score\n recursive_depth_of(self.root.right_child, score, 0)\n elsif score < self.root.score\n recursive_depth_of(self.root.left_child, score, 0)\n end\n end",
"def depth; end",
"def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end",
"def height\n return 0 if @root == nil\n return 1 if @root && (@root.left == nil && @root.right == nil)\n height_helper(@root, 0)\n end",
"def find_max_depth(node, depth=0)\n if node.nil?\n return depth\n else\n left_depth = find_max_depth(node.left, depth + 1)\n right_depth = find_max_depth(node.right, depth + 1)\n if left_depth > right_depth\n return left_depth\n else\n return right_depth\n end\n end\n end",
"def my_depth\n 1\n end",
"def depth\n @attributes[:depth]\n end",
"def depth\n return 0 if nil?\n\n @accumulator_depth = 1\n depth_aux(self, @accumulator_depth)\n @accumulator_depth\n end",
"def height\n if @root.nil?\n return 0\n elsif @root.left.nil? && @root.right.nil?\n return 1\n end\n return height_helper(@root)\n end",
"def test_level\n assert_equal(0, @root.level, \"A root node's level is 0\")\n\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n\n setup_test_tree\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.level, \"Node #{child.name} should have level 1\")\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n end\n\n assert_equal(2, @child4.level, \"Child 4 should have level 2\")\n end",
"def height_with_recursion(root)\n return 0 unless root\n leftDepth = height_with_recursion(root.left)\n rightDepth = height_with_recursion(root.right)\n (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1\n end",
"def depth_min; depths.min end",
"def num_tree_levels\n level = 0\n num_nodes= all_node_values_with_nil.length # considers tree as 'complete\n num_nodes_in_full_tree = 2**level\n until num_nodes_in_full_tree >= num_nodes\n level += 1\n num_nodes_in_full_tree += 2**level\n end\n num_tree_levels = level + 1 # (started count at 0)\n num_tree_levels = 0 if @root.nil?\n return num_tree_levels\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def test_depth=\n @br.depth = 100\n end",
"def maximum_depth(node, depth = 0)\n @h = depth\n node.descendants.map{|d| @h = d.depth if d.depth >= @h }\n @h \nend",
"def get_depth(id)\n if id.nil?\n return 0\n end\n \n old_pairing = AssignmentPairing.find_by_assignment_id(id)\n if old_pairing.nil? \n return 0\n end\n\n old_pairing.depth + 1\n end",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def depth(person)\n count = 0\n \n until person.ancestor == nil do\n person = person.ancestor\n count += 1\n end\n\n count\n end",
"def depth_of(score)\n if include?(score) #This is calling the method on line 44\n 1 + @root_node.depth_of(score) \n else \n nil\n end \nend",
"def current_depth\n 0\n end",
"def depth\n crumbs.size\n end",
"def test_add_third_node_to_right\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(60, \"movie b\")\n movie_c = tree.insert(70, \"movie c\")\n assert_equal 2, tree.root.right_node.right_node.depth\n end",
"def depth_helper(node, arr, depth)\n if node.left.nil? && node.right.nil? \n arr << depth\n return\n else \n depth += 1 \n if node.left\n depth_helper(node.left, arr, depth) \n end \n if node.right\n depth_helper(node.right, arr, depth)\n end \n end \n end",
"def test_depth_zero\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,100]\n end\n assert_equal(0, bbox.depth,\n 'Failed in test_depth_zero' )\n end",
"def i_am_not_too_deep?(depth)\n depth <= @depth_to_explore\n end",
"def depth_traversal(node, &block)\n yield node.value # print the current block\n\n # recurse down to the left child\n depth_traversal(node.left, &block) if node.left\n\n # recurse down to the right child\n depth_traversal(node.right, &block) if node.right\nend",
"def test_add_third_node_to_left\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n movie_c = tree.insert(30, \"movie c\")\n assert_equal 2, tree.root.left_node.left_node.depth\n end",
"def depth(d)\n @depth = d\n self\n end",
"def max_depth(root)\n return 0 if root.nil?\n\n left_depth = max_depth(root.left)\n right_depth = max_depth(root.right)\n\n (left_depth > right_depth ? left_depth : right_depth) + 1\nend",
"def balanced?\n difference_left_right = @root.left_child.depth - @root.right_child.depth\n difference_left_right.between?(-1, 1)\n end",
"def host_depth_divisor\n 1.0 / domain_depth_coef\n end",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def max_depth(root)\n current_node = root\n\n if current_node.nil?\n return 0\n else\n [max_depth(current_node.left), max_depth(current_node.right)].max + 1\n # max_left_depth = max_depth(current_node.left)\n # max_right_depth = max_depth(current_node.right)\n\n # if max_left_depth >= max_right_depth\n # return max_left_depth + 1\n # else\n # return max_right_depth + 1\n # end\n end\nend",
"def dfs(root, depth)\n return if root.nil?\n @f[depth] = @f[depth].to_i + root.val\n dfs(root.left, depth + 1) if root.left\n dfs(root.right, depth + 1) if root.right\nend",
"def depth\n @breadcrumb.scan( \"/\" ).size\n end",
"def current_depth\n current = Fiber.current\n managed_fiber?(current) ? current.depth : 0\n end",
"def orbit_count\n return 0 unless @root\n sum_of_depths = 0\n nodes_to_traverse = [{ node: @root, depth: 0 }]\n until nodes_to_traverse.empty?\n node_pair = nodes_to_traverse.shift\n node = node_pair[:node]\n depth = node_pair[:depth]\n sum_of_depths += depth\n node.children.each { |child| nodes_to_traverse << { node: child, depth: depth + 1 } }\n end\n sum_of_depths\n end",
"def is_balanced(root)\n return true if root.nil?\n left_height = depth(root.left)\n right_height = depth(root.right)\n result = (left_height - right_height).abs\n return false if result > 1\n return is_balanced(root.left) && is_balanced(root.right)\nend",
"def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end",
"def height(node, height_num = 0)\n #1. get the node from the tree that we are starting from if it's not the correct class\n if (node != nil && node.class != Node)\n node = find_node(node)\n #1.5 recurisvely return height_num if node has no children\n end\n if(node.nil? || node.left.nil? && node.right.nil?)\n return height_num \n end\n height_num += 1 \n #4. start a recursive call on the left node to travel down all of it's node\n right_height_value = height(node.right,height_num)\n #5. compare values of left and right recursive values\n left_height_value = left_height(node.left) \n result = left_height_value > right_height_value ? left_height_value : right_height_value\n #6. return the value of the height of the node\n return result\n end",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def max_depth(node)\n return 0 if node.nil?\n [max_depth(node.left), max_depth(node.right)].max + 1\nend",
"def leaves(node, depth=0)\n if node.left.nil? && node.right.nil?\n puts \"#{node.value}, depth: #{depth}\"\n return 1\n else\n leaves(node.left, depth+1) + leaves(node.right, depth+1)\n end\nend",
"def get_height_wid_recursion(node = root)\n if node.nil?\n return 0\n end\n ldepth = get_height_wid_recursion(node.left)\n rdepth = get_height_wid_recursion(node.right)\n depth = [ldepth, rdepth].max + 1\n return depth\n end",
"def height\n return @tree_height\n end",
"def depth\n PathExpression.range(path)[1]\n end",
"def max_depth(root)\n return 0 if root.nil?\n\n left_result = max_depth(root.left)\n right_result = max_depth(root.right)\n\n return (left_result > right_result ? left_result : right_result) + 1\nend",
"def height\n height_recursive(@root)\n end",
"def total_depth(depth_phase1, max_depth)\n mv = 0\n d1 = 0\n d2 = 0\n max_depth_phase2 = [10, max_depth - depth_phase1].min # max 10 moves in phase 2\n depth_phase1.times do |i|\n mv = 3 * move_axis[i] + move_power[i] - 1\n urf_to_dlf[i + 1] = Cache.urf_to_dlf_move[urf_to_dlf[i]][mv]\n fr_to_br[i + 1] = Cache.fr_to_br_move[fr_to_br[i]][mv]\n parity[i + 1] = Cache.parity_move[parity[i]][mv]\n end\n\n d1 = Cache::BasePrune.get_pruning(\n Cache.slice_urf_to_dlf_parity_prune,\n (Cache::BaseCache::N_SLICE2 * urf_to_dlf[depth_phase1] + fr_to_br[depth_phase1]) * 2 + parity[depth_phase1]\n )\n return -1 if d1 > max_depth_phase2\n\n depth_phase1.times do |i|\n mv = 3 * move_axis[i] + move_power[i] - 1\n ur_to_ul[i + 1] = Cache.ur_to_ul_move[ur_to_ul[i]][mv]\n ub_to_df[i + 1] = Cache.ub_to_df_move[ub_to_df[i]][mv]\n end\n\n ur_to_df[depth_phase1] = Cache.merge_ur_to_ul_and_ub_to_df[ur_to_ul[depth_phase1]][ub_to_df[depth_phase1]]\n\n d2 = Cache::BasePrune.get_pruning(\n Cache.slice_ur_to_df_parity_prune,\n (Cache::BaseCache::N_SLICE2 * ur_to_df[depth_phase1] + fr_to_br[depth_phase1]) * 2 + parity[depth_phase1]\n )\n return -1 if d2 > max_depth_phase2\n\n min_dist_phase2[depth_phase1] = [d1, d2].max\n return depth_phase1 if min_dist_phase2[depth_phase1] == 0 #already solved\n\n # set up search\n depth_phase2 = 1\n n = depth_phase1\n busy = false\n move_power[depth_phase1] = 0\n move_axis[depth_phase1] = 0\n min_dist_phase2[n + 1] = 1 # else failure for depth_phase2=1, n=0\n ####\n\n while true\n while true\n if depth_phase1 + depth_phase2 - n > min_dist_phase2[n + 1] and !busy\n if move_axis[n] == 0 || move_axis[n] == 3\n n += 1\n move_axis[n] = 1\n move_power[n] = 2\n else\n n += 1\n move_axis[n] = 0\n move_power[n] = 1\n end\n else\n if move_axis[n] == 0 || move_axis[n] == 3\n move_power[n] += 1\n else\n move_power[n] += 2\n end\n\n if move_power[n] > 3\n while true\n # increment axis\n move_axis[n] += 1\n if move_axis[n] > 5\n if n == depth_phase1\n if depth_phase2 >= max_depth_phase2\n return -1\n else\n depth_phase2 += 1\n move_axis[n] = 0\n move_power[n] = 1\n busy = false\n break\n end\n else\n n -= 1\n busy = true\n break\n end\n else\n if move_axis[n] == 0 || move_axis[n] == 3\n move_power[n] = 1\n else\n move_power[n] = 2\n end\n\n busy = false\n end\n\n break unless n != depth_phase1 && (move_axis[n - 1] == move_axis[n] || move_axis[n - 1] - 3 == move_axis[n])\n end\n else\n busy = false\n end\n end\n\n break unless busy\n end\n\n # compute new coordinates and new minDist\n mv = 3 * move_axis[n] + move_power[n] - 1\n urf_to_dlf[n + 1] = Cache.urf_to_dlf_move[urf_to_dlf[n]][mv]\n fr_to_br[n + 1] = Cache.fr_to_br_move[fr_to_br[n]][mv]\n parity[n + 1] = Cache.parity_move[parity[n]][mv]\n ur_to_df[n + 1] = Cache.ur_to_df_move[ur_to_df[n]][mv]\n\n min_dist_phase2[n + 1] = [\n Cache::BasePrune.get_pruning(\n Cache.slice_ur_to_df_parity_prune,\n (Cache::BaseCache::N_SLICE2 * ur_to_df[n + 1] + fr_to_br[n + 1]) * 2 + parity[n + 1]\n ),\n Cache::BasePrune.get_pruning(\n Cache.slice_urf_to_dlf_parity_prune,\n (Cache::BaseCache::N_SLICE2 * urf_to_dlf[n + 1] + fr_to_br[n + 1]) * 2 + parity[n + 1]\n )\n ].max\n\n break if min_dist_phase2[n + 1] == 0\n end\n\n depth_phase1 + depth_phase2\n end",
"def depth(key, count = 0, child = key)\n count += 1\n if root.data == child\n return count - 1\n else\n parent = find_parent(child).data\n depth(key, count, parent)\n end\n end",
"def http_depth(default = DEPTH_INFINITY)\n # If its not set, we'll grab the default\n depth = @http_request.header('Depth')\n\n return default unless depth\n\n return DEPTH_INFINITY if depth == 'infinity'\n\n # If its an unknown value. we'll grab the default\n return default unless depth =~ /^[\\+\\-0-9\\.]$/ # TODO: valid replacement for ctype_digit?\n\n depth.to_i\n end",
"def too_deep?( depth )\n depth.to_i > 0 && (depth + 1) <= path.to_s.count( '/' )\n end",
"def balanced?(tree_root)\n return true unless tree_root\n depths = []\n nodes = []\n nodes << [tree_root, 0]\n until nodes.empty?\n node, depth = nodes.pop\n if !node.left && !node.right\n unless depths.include?(depth)\n depths.push(depth)\n if depths.length > 2 || depths.length == 2 && (depths[0] - depths[1]).abs > 1\n return false\n end\n end\n else\n nodes << [node.left, depth + 1] if node.left\n nodes << [node.right, depth + 1] if node.right\n end\n end\n true\nend",
"def is_balanced?(tree_node = @root)\n left_depth = depth(tree_node.left)\n right_depth = depth(tree_node.right)\n\n return left_depth == right_depth\n\n end",
"def max_depth root\n return 0 if root == nil\n\n [max_depth(root.left), max_depth(root.right)].max + 1\nend"
] |
[
"0.6864693",
"0.6757938",
"0.6713219",
"0.6686807",
"0.6681568",
"0.6674517",
"0.65427613",
"0.6526818",
"0.65262014",
"0.6513792",
"0.64473724",
"0.64045507",
"0.63973296",
"0.6364339",
"0.6276778",
"0.6271265",
"0.6258746",
"0.62341547",
"0.6209124",
"0.6202515",
"0.6086186",
"0.60818297",
"0.60419166",
"0.60286397",
"0.6018679",
"0.60173005",
"0.60138404",
"0.59787637",
"0.59713525",
"0.59526813",
"0.5935305",
"0.59317654",
"0.5930428",
"0.59202677",
"0.5911242",
"0.5903669",
"0.590114",
"0.5862266",
"0.5851227",
"0.5847466",
"0.5840574",
"0.5827546",
"0.58261013",
"0.58109635",
"0.5797963",
"0.5773982",
"0.57565796",
"0.575249",
"0.5711486",
"0.5704416",
"0.5704324",
"0.56992084",
"0.5688686",
"0.5685969",
"0.5674502",
"0.5659362",
"0.564585",
"0.56377584",
"0.56349903",
"0.55891645",
"0.55683476",
"0.5567683",
"0.55640554",
"0.55271226",
"0.55156875",
"0.5515244",
"0.5506551",
"0.54916453",
"0.5487434",
"0.5473927",
"0.54728854",
"0.54690737",
"0.5456672",
"0.54535484",
"0.5440825",
"0.5438661",
"0.54303956",
"0.542609",
"0.54204446",
"0.5408896",
"0.5398571",
"0.5388117",
"0.53848803",
"0.53805834",
"0.5379902",
"0.5375425",
"0.5367308",
"0.53646123",
"0.5339534",
"0.5330652",
"0.5321446",
"0.53072166",
"0.5297882",
"0.5297094",
"0.52920896",
"0.5292085",
"0.5285424",
"0.5278585",
"0.52688086",
"0.5256176"
] |
0.74402314
|
0
|
Test the level method. Since this is an alias of node_depth, we just test for equivalence
|
def test_level
assert_equal(0, @root.level, "A root node's level is 0")
assert_equal(@root.node_depth, @root.level, "Level and depth should be the same")
setup_test_tree
for child in [@child1, @child2, @child3]
assert_equal(1, child.level, "Node #{child.name} should have level 1")
assert_equal(@root.node_depth, @root.level, "Level and depth should be the same")
end
assert_equal(2, @child4.level, "Child 4 should have level 2")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def get_node_level(node, key)\n get_level_of_node(node, key, 1)\nend",
"def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end",
"def difficulty_level_limit(level)\n @depth == level ? true : false\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def levels?\n @levels\n end",
"def level_order_traversal(node)\n h = height(node)\n (1..h).each do |n|\n print_given_level(node, n)\n end\nend",
"def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def is_at_least_level?(level)\n return false if !ADMIN_RANKING[level] or !ADMIN_RANKING[self.role]\n return ADMIN_RANKING[self.role] >= ADMIN_RANKING[level]\n end",
"def level_up?\n # result of level up and set current level is now last known level\n result, @old_level = (@old_level < @level), @level\n # return result\n return result\n end",
"def ==(other_level)\n @grid == other_level.grid\n end",
"def level; end",
"def level; end",
"def level; end",
"def level; end",
"def level; end",
"def level; end",
"def depth_support(node)\n return 0 if node.nil?\n l_depth = depth_support(node.left)\n r_depth = depth_support(node.right)\n [l_depth, r_depth].max + 1\n end",
"def level_filtered?(level)\n LEVELS.index(level) < LEVELS.index(@level)\n end",
"def do_deprecated_depth\n assert_equal(1, @root.depth, \"A single node's depth is 1\")\n\n @root << @child1\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @root << @child2\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @child2 << @child3\n assert_equal(3, @root.depth, \"This should be of depth 3\")\n assert_equal(2, @child2.depth, \"This should be of depth 2\")\n\n @child3 << @child4\n assert_equal(4, @root.depth, \"This should be of depth 4\")\n end",
"def update_depth\n if depth?\n self.update_attribute(:depth, level)\n end\n self\n end",
"def my_depth\n 1\n end",
"def leaf?\n level.zero?\n end",
"def level\n @level\n end",
"def level\n @level\n end",
"def safe_level(*) end",
"def level\n if parent.nil?\n 0\n else\n parent.level + 1;\n end\n end",
"def get_depth\n raise \"Not implemented\"\n end",
"def test(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"test failed level #{l} ,inconsistent node(s) #{difference}\" if (difference.count != 0)\n end\n puts \"test complete\"\nend",
"def level\n return 0 if root?\n\n @parent.level + 1\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def depth\n depth_support(self.root)\n end",
"def level\n @level || Helpers.char_level(@entity)\n end",
"def level\n @level\n end",
"def level\r\n\tif $lvl == 1\r\n\t\tlevel2\r\n\telse \r\n\t\tif $lvl == 2\r\n\t\t\tlevel3\r\n\t\telse\r\n\t\t\tif $lvl == 3\r\n\t\t\t\tlevel4\r\n\t\t\tend\r\n\t\tend\t\r\n\tend\t\r\nend",
"def level\n is_root? ? nil : option_set.try(:level, depth)\n end",
"def depth()\n #This is a stub, used for indexing\n end",
"def level\n parent_id.nil? ? 0 : compute_level\n end",
"def level_up\r\r\n return unless can_level\r\r\n return if @level == @max_level\r\r\n @level += 1\r\r\n if @special == nil then\r\r\n @special = 0\r\r\n end\r\r\n level_update\r\r\n end",
"def nil_check\n self.level = self.level || 0\n end",
"def check_level(max, current)\n if max == \"u\"\n return current == \"u\"\n end\n if max == \"s\"\n return %w{u s}.include?(current)\n end\n # OK\n return TRUE\nend",
"def level\n init unless @initialized\n level = level_to_sym(@level)\n end",
"def level\n return 0 if self[acts_as_nested_set_options[:parent_column]].nil?\n self.class.count(\"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} < #{self[acts_as_nested_set_options[:left_column]]} and #{acts_as_nested_set_options[:right_column]} > #{self[acts_as_nested_set_options[:right_column]]})\")\n end",
"def level\n root? ? 0 : ancestors.count\n end",
"def levels(level_counter = 0)\n level_counter += 1\n #puts \"value: #{value}, level_counter: #{level_counter}\"\n\n if left.nil? && right.nil?\n return level_counter\n end\n\n left_levels = left ? left.levels(level_counter) : 0\n right_levels = right ? right.levels(level_counter) : 0\n\n if left_levels > right_levels\n return left_levels\n else\n return right_levels\n end\n end",
"def log?(level, other_level)\n compare_levels(level, other_level) != :gt\n end",
"def children?(this_level)\n @reader.level > this_level\n end",
"def depth; end",
"def test_depth_of_root\n tree = BinarySearchTree.new\n tree.insert(13, \"Test1\")\n assert_equal tree.depth_of(13), 0\n end",
"def test_depth=\n @br.depth = 100\n end",
"def reorder_level?\n end",
"def update_level\n #if is_literal?\n if @left_sentence.nil? && @right_sentence.nil?\n @level = @father.level\n else\n @level = @father.level + 1\n @left_sentence.update_level unless @left_sentence.nil?\n @right_sentence.update_level unless @right_sentence.nil?\n end\n end",
"def level_index\n @level_index || 0\n end",
"def level_index\n @level_index || 0\n end",
"def depth_of(score)\n if include?(score) #This is calling the method on line 44\n 1 + @root_node.depth_of(score) \n else \n nil\n end \nend",
"def level\n return @level\n end",
"def level\n return @level\n end",
"def current_depth\n 0\n end",
"def level\n level = 0\n while get_points >= rounded_maximum_points_for_level(level)\n level += 1\n end\n level\n end",
"def level\n case\n when root? then 0\n when depth_column_could_be_used? then depth\n when parent_association_loaded? then parent.level + 1\n # @todo move it adapters\n else ancestors.size\n end\n end",
"def height_helper(current_node, level = 0)\n return level if !current_node\n level = [height_helper(current_node.left, level + 1), height_helper(current_node.right, level + 1)].max\n return level\n end",
"def info?; @level <= INFO; end",
"def info?; @level <= INFO; end",
"def state_depth_must_be(level)\n states[0..level].each do |a|\n raise 'factory state error' if a.nil?\n end\n end",
"def level(value = nil)\n if value.nil?\n @level\n else\n @level = value\n end\n end",
"def level\n\t\tlevel = 0\n\t\t@classes.each do |_class|\n\t\t\tlevel += _class.level\n\t\tend\n\t\tlevel\n\tend",
"def leaf?\n right - left == 1\n end",
"def reached_new_level?\n return false unless points_awarded && points_awarded_changed?\n\n level_after_update.level_number > level_before_update.level_number\n end",
"def depth\n @traversal_position.depth\n end",
"def level(circle = self)\n return 0 unless circle.super_circle\n\n 1 + level(circle.super_circle)\n end",
"def levelOrderTraversal(current_node = @root)\n \treturn \"Tree is empty\" if !current_node\n \tlevel = 1\n \tqueue = Array.new\n \tqueue.push current_node\n \tqueue.push '$' # To identify end of level\n \tp \"Level = #{level}\"\n \twhile queue.size != 1\n \t\ttop_element = queue.shift\n \t\tif top_element != '$'\n\t \t\tp top_element.value\n\t \t\tqueue.push top_element.left if top_element.left\n\t \t\tqueue.push top_element.right if top_element.right\n\t \telse\n\t \t\tlevel += 1\n\t \t\tp \"Level = #{level}\"\n\t \t\tqueue.push top_element\n\t \tend\n \tend\n \treturn level\n end",
"def print_level?(min_level, level)\n printed_levels(min_level).include?(level)\n end",
"def check_integrity(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"stray node found in level: #{l} which is #{list.to_a(nil,nil,nil,l)}\" if !difference.empty? \n expect(difference).to match_array([])\n end\nend",
"def check_level_param\n if (!params[:level].blank? && params[:level].to_i.to_s == params[:level] && User.valid_level?(params[:level].to_i))\n @level = params[:level].to_i\n end\n\n return @level\n end",
"def test_depth_simple\n bbox = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox = bbox.add [100,100,100]\n bbox = bbox.add [200,200,200]\n end\n assert_equal(100, bbox.depth,\n 'Failed in test_depth_simple' )\n end",
"def max_level_depth\n MAXIMUM_LEVEL_DEPTH\n end",
"def getLevels\n @level\n end",
"def calculate_level\n # Increase level for every 10 lines cleared\n @level = @start_level + (@lines_cleared / 10).floor\n end",
"def num_tree_levels\n level = 0\n num_nodes= all_node_values_with_nil.length # considers tree as 'complete\n num_nodes_in_full_tree = 2**level\n until num_nodes_in_full_tree >= num_nodes\n level += 1\n num_nodes_in_full_tree += 2**level\n end\n num_tree_levels = level + 1 # (started count at 0)\n num_tree_levels = 0 if @root.nil?\n return num_tree_levels\n end",
"def current_level\n @cur_level\n end",
"def user_reach_level(achievement, user)\n user_tree = TreeService::UserTreeFetcher.new(user, nil)\n user_tree.depth == achievement.settings['level']\n end",
"def root?\n self.depth.zero?\n end",
"def root?\n self.depth.zero?\n end",
"def level \n if (self.parent_category_id == nil)\n @level = 1\n elsif (@level == nil) \n @level = computeLevelBySQL\n end \n @level\nend",
"def at_depth(depth)\n where \"NLEVEL(#{table_name}.#{ltree_path_column}) = ?\", depth\n end",
"def lvlres\n @level = 0\n lvlup\n end",
"def set_level current_depth, current_element,next_element\n if next_element.level > current_element.level\n current_depth.push current_element \n elsif next_element.level < current_element.level\n current_depth.pop \n end\n #if depths are equal, or next item doesn't exist, return same level\n current_depth\n end",
"def get_level(key)\n case key\n when \"L\", \"l\" then 0 # Level L\n when \"M\", \"m\" then 1 # Level M\n when \"Q\", \"q\" then 2 # Level Q\n when \"H\", \"h\" then 3 # Level H\n end\n end",
"def test_insert_second_node_returns_depth\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n assert_equal 1, tree.root.left_node.depth\n end",
"def i_am_not_too_deep?(depth)\n depth <= @depth_to_explore\n end",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def one_level\n improvement = false\n nb_passes = 0\n cur_mod = @graph.modularity\n new_mod = cur_mod\n begin\n cur_mod = new_mod\n nb_moves = 0\n nb_passes += 1\n @graph.nodes.shuffle.each do |node|\n orig_community = @graph.get_community node\n\n neighbour_communities = @graph.get_neighbour_comms node\n\n @graph.remove_node node, orig_community\n\n\n best_community = orig_community\n max_gain = 0.0\n\n neighbour_communities.each do |comm|\n mod_gain = @graph.modularity_gain node, comm\n if mod_gain > max_gain\n max_gain = mod_gain\n best_community = comm\n end\n end\n if best_community != orig_community\n nb_moves += 1\n improvement = true\n end\n\n @graph.insert_node node, best_community\n\n @graph.garbage_collect orig_community\n\n end\n new_mod = @graph.modularity\n end while nb_moves > 0 and new_mod - cur_mod >= MIN_INCREASE\n return improvement\n end",
"def _level? level\n\t\t_throw Sl[:'your level is too low'] if _user[:level].to_i < level.to_i\n\tend",
"def info?\n @level <= 1\n end",
"def equivalent_level\n 0\n end",
"def level=(value)\n @level = value\n end",
"def level=(value)\n @level = value\n end"
] |
[
"0.6713321",
"0.64925057",
"0.64134645",
"0.63959444",
"0.63704574",
"0.63364893",
"0.6289961",
"0.62431514",
"0.6223875",
"0.6188657",
"0.6180239",
"0.61747295",
"0.61284477",
"0.6109462",
"0.6109462",
"0.6109462",
"0.6109462",
"0.6109462",
"0.6109462",
"0.6109397",
"0.6106468",
"0.61046046",
"0.60935634",
"0.6079687",
"0.60750794",
"0.60248923",
"0.60248923",
"0.601503",
"0.6014168",
"0.59905034",
"0.5932424",
"0.5932127",
"0.5916194",
"0.59120697",
"0.5907671",
"0.58978575",
"0.5890876",
"0.58898115",
"0.5884861",
"0.58788615",
"0.5865303",
"0.5844079",
"0.5843716",
"0.5822796",
"0.5812224",
"0.5799888",
"0.57984763",
"0.5796135",
"0.57904184",
"0.5787348",
"0.5778486",
"0.577253",
"0.5770954",
"0.5769071",
"0.5768875",
"0.5763769",
"0.5763769",
"0.5751855",
"0.5731647",
"0.5731647",
"0.5731126",
"0.5728123",
"0.5718453",
"0.57057804",
"0.5699187",
"0.5699187",
"0.5689049",
"0.56884444",
"0.56874627",
"0.56846905",
"0.5675241",
"0.565419",
"0.56313384",
"0.5625513",
"0.5625314",
"0.5623004",
"0.56078595",
"0.5592368",
"0.55905145",
"0.5590509",
"0.55899644",
"0.55844563",
"0.55823535",
"0.5571141",
"0.5545686",
"0.5545686",
"0.5534226",
"0.5531951",
"0.5523266",
"0.55230236",
"0.5516628",
"0.55108684",
"0.55070376",
"0.55062",
"0.54889625",
"0.548805",
"0.5485769",
"0.5469728",
"0.546319",
"0.546319"
] |
0.74802727
|
0
|
Test the breadth computation algorithm
|
def test_breadth
assert_equal(1, @root.breadth, "A single node's breadth is 1")
@root << @child1
assert_equal(1, @root.breadth, "This should be of breadth 1")
@root << @child2
assert_equal(2, @child1.breadth, "This should be of breadth 2")
assert_equal(2, @child2.breadth, "This should be of breadth 2")
@root << @child3
assert_equal(3, @child1.breadth, "This should be of breadth 3")
assert_equal(3, @child2.breadth, "This should be of breadth 3")
@child3 << @child4
assert_equal(1, @child4.breadth, "This should be of breadth 1")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend",
"def bfs\n\n\n end",
"def test\n puts 'Building Graph for tests...'\n # Simple graph\n #\n # First\n # / \\\n # second third\n # / | | \\\n # fourth fifth goal sixth\n #\n # Construct graph\n first = GraphNode.new 'First'\n second = GraphNode.new 'Second'\n third = GraphNode.new 'Third'\n fourth = GraphNode.new 'Fourth'\n fifth = GraphNode.new 'Fifth'\n sixth = GraphNode.new 'Sixth'\n goal = GraphNode.new 'Goal'\n\n first.connect second\n first.connect third\n\n second.connect first\n second.connect fourth\n second.connect fifth\n\n third.connect first\n third.connect goal\n third.connect sixth\n\n fourth.connect second\n fifth.connect second\n\n goal.connect third\n sixth.connect third\n\n # Perform tests\n puts \"Testing from root node 'First'\"\n puts(bfs(first) { |node| puts ' ' + node })\n\n puts \"Testing from second node 'Second'\"\n puts(bfs(second) { |node| puts ' ' + node })\nend",
"def bfs\n # raise NotImplementedError\n end",
"def BFT_iterative(root)\n print '[\"I\", \"O\", \"H\", \"L\", \"R\", \"T\", \"M\", \"A\", \"G\"]' + \"\\n\"\n if root == nil\n return\n end\n q = Queue.new\n q.enqueue(root)\n\n while !q.empty?\n root = q.dequeue # I\n print(\"#{root.value}\\n\") \n if !root.left.nil?\n q.enqueue(root.left)\n end\n if !root.left.nil?\n q.enqueue(root.right)\n end\n end\n end",
"def bfs\n\n end",
"def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= 1\n queue.push(neighbor) if @in_degrees[neighbor].zero?\n end\n end\n\n visited.size == @num_courses ? visited : []\n end",
"def breadth_first(value)\n\tend",
"def calc\n # If the searches have not started\n if breadth_first_search.visited.empty?\n # Calculate the two searches\n calc_breadth_first\n calc_dijkstra\n end\n end",
"def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end",
"def test_bfs(tree, location, expect_match = true)\n puts \"\\n-----------------------------------------------------------------\\n \"\n puts \"Testing bfs method...\"\n puts \"\\nInitial location: Tree Root = [#{tree.root.location.to_s}]\\n \"\n node_match = tree.bfs(location)\n results_match = true\n if expect_match\n if node_match.nil?\n results_match = false\n else\n puts \"Node match found for [#{location[0]}, #{location[1]}]\"\n node_match.show_stats\n results_match = false unless node_match.location == location\n end\n else\n puts \"No match found\"\n results_match = false unless node_match.nil?\n end\n puts \">>>>>> ERROR <<<<<\" unless results_match\n puts \"\\n-----------------------------------------------------------------\\n \"\nend",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs(starting_node, target_value)\n return starting_node if starting_node.value == target_value\n queue = [starting_node]\n until queue.empty?\n queue += starting_node.neighbors\n queue.each { |neighbor| bfs(neighbor, tar) }\n end\n nil\nend",
"def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end",
"def bfs_for(coords, current_node = @tree, queue = [], hit_squares = [], benchmark = false)\n\t\tif is_current_square_match?(coords, current_node)\n\t\t\tmatch_found(coords, current_node, benchmark)\n\t\telse\n\t\t\thit_squares << get_coords_from_node(current_node)\n\t\t\tcurrent_node.children.each {|child| queue.unshift(child) unless hit_squares.include?(get_coords_from_node(child))} if current_node.children\n\t\t\tnext_node = queue.pop\n\t\t\tnext_node.nil? ? not_found(coords, benchmark) : bfs_for(coords, next_node, queue, hit_squares, benchmark) \n\t\tend\n\tend",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def unit_test_binary_tree\n node_a = Node.new('A', nil, nil, nil)\n node_b = Node.new('B', nil, nil, nil)\n node_c = Node.new('C', nil, nil, nil)\n node_d = Node.new('D', nil, nil, nil)\n node_e = Node.new('E', nil, nil, nil)\n node_f = Node.new('F', nil, nil, nil)\n node_g = Node.new('G', nil, nil, nil)\n node_h = Node.new('H', nil, nil, nil)\n node_i = Node.new('I', nil, nil, nil)\n node_j = Node.new('J', nil, nil, nil)\n\n tree = Tree.new(nil)\n\n p \"-------------------- BEGIN CONSTRUCTING TREE -------------------- \"\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A D I \"\n p \" // \\\\ // \"\n p \" C E H \"\n\n p \"-------------------- END CONSTRUCTING TREE -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN INRODER TREE WALK -------------------- \"\n p inorder_tree_walk(tree.root)\n p \"-------------------- END INRODER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN PREORDER TREE WALK -------------------- \"\n p preoder_tree_walk(tree.root)\n p \"-------------------- END PREORDER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN POSTORDER TREE WALK -------------------- \"\n p postorder_tree_walk(tree.root)\n p \"-------------------- END PREORDER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN RECURSIVE TREE SEARCH -------------------- \"\n p tree_search(tree.root, 'I')\n p \"-------------------- END RECURSIVE TREE SEARCH -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN ITERATIVE TREE SEARCH -------------------- \"\n p iterative_tree_search(tree.root, 'I')\n p \"-------------------- END ITERATIVETREE SEARCH -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR TREE MIN -------------------- \"\n p tree_minimum(tree.root)\n p \"-------------------- END SEARCHING FOR TREE MIN -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING TREE MAX -------------------- \"\n p tree_maximum(tree.root)\n p \"-------------------- END SEARCHING TREE MAX -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR SUCCESSOR -------------------- \"\n p tree_successor(node_g)\n p \"-------------------- END SEARCHING FOR SUCCESSOR -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR PREDECESSOR -------------------- \"\n p tree_predecessor(node_g)\n p \"-------------------- END SEARCHING FOR PREDECESSOR -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE INSERTION -------------------- \"\n tree_insert(tree, node_j)\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A D I \"\n p \" // \\\\ // \\\\ \"\n p \" C E H J \"\n p \"-------------------- END NODE INSERTION -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE DELETION (SUCCESSOR) -------------------- \"\n tree_delete(tree, node_d)\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A E I \"\n p \" // // \\\\ \"\n p \" C H J \"\n p \"-------------------- END NODE DELETION (SUCCESSOR) -------------------- \"\n preoder_tree_walk(tree.root)\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE DELETION (PREDECESSOR) -------------------- \"\n tree_delete_predecessor(tree, node_b)\n p \" F \"\n p \" // \\\\ \"\n p \" A G \"\n p \" \\\\ \\\\ \"\n p \" E I \"\n p \" // // \\\\ \"\n p \" C H J \"\n p \"-------------------- END NODE DELETION (PREDECESSOR) -------------------- \"\n preoder_tree_walk(tree.root)\n end",
"def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def run_tests\n desc = 'valid full tree'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(30)\n right = tree.insert_right(70)\n left.insert_left(10)\n left.insert_right(40)\n right.insert_left(60)\n right.insert_right(80)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\n\n desc = 'both subtrees valid'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(30)\n right = tree.insert_right(80)\n left.insert_left(20)\n left.insert_right(60)\n right.insert_left(70)\n right.insert_right(90)\n result = binary_search_tree?(tree)\n assert_false(result, desc)\n\n desc = 'descending linked list'\n tree = BinaryTreeNode.new(50)\n left = tree.insert_left(40)\n left_left = left.insert_left(30)\n left_left_left = left_left.insert_left(20)\n left_left_left.insert_left(10)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\n\n desc = 'out of order linked list'\n tree = BinaryTreeNode.new(50)\n right = tree.insert_right(70)\n right_right = right.insert_right(60)\n right_right.insert_right(80)\n result = binary_search_tree?(tree)\n assert_false(result, desc)\n\n desc = 'one node tree'\n tree = BinaryTreeNode.new(50)\n result = binary_search_tree?(tree)\n assert_true(result, desc)\nend",
"def breadth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n queue = []\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n connections.each do |i|\n if i.value == find\n answer = i\n condition = true\n elsif !visited.include?(i)\n visited.push(i)\n queue.push(i)\n end\n end\n end\n current = queue.shift\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend",
"def bfs(tree, value)\n q = MyQueue.new\n q.enqueue(tree)\n current_tree = q.dequeue() #need to do something when i dequeue \n \n while current_tree != nil\n puts current_tree.payload\n\n if current_tree.payload != value\n current_tree.children.each do |leaf|\n q.enqueue(leaf)\n end\n else\n q = MyQueue.new\n end\n current_tree = q.dequeue()\n end\nend",
"def test_branch_chain2\n #puts \"---------------test_branch_chain2-----------------\"\n\n t1= t2 = t11 = t12 = t21 = t23 = t31 = t32 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do\n b.chain do\n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n b.chain do\n b.branch do\n t21 = b.add(Thing21.new)\n b.chain do\n t31 = b.add(Thing31.new)\n t32 = b.add(Thing32.new)\n end\n end\n t23 = b.add(Thing23.new)\n end\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12,t21,t23,t31,t32])\n assert r.include? [t1,t11]\n assert r.include? [t1,t21]\n assert r.include? [t1,t31]\n\n assert r.include? [t11,t12]\n assert r.include? [t12,t2]\n\n assert r.include? [t21,t23]\n assert r.include? [t23,t2]\n\n assert r.include? [t31,t32]\n assert r.include? [t32,t23]\n\n assert_equal 9, r.size\n end",
"def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end",
"def bellman_test()\n\n graph = [\n [0, 2, 2, 2, -1], # 0 = Start\n [9, 0, 2, 2, -1], # 1 = Bunny 0\n [9, 3, 0, 2, -1], # 2 = Bunny 1\n [9, 3, 2, 0, -1], # 3 = Bunny 2\n [9, 3, 2, 2, 0], # 4 = Bulkhead\n ]\n\n # Start End Delta Time Status\n # - 0 - 1 Bulkhead initially open\n # 0 4 -1 2\n # 4 2 2 0\n # 2 4 -1 1\n # 4 3 2 -1 Bulkhead closes\n # 3 4 -1 0 Bulkhead reopens; you and the bunnies exit\n\n\n # graph = [\n # [0, 1, 1, 1, 1],\n # [1, 0, 1, 1, 1],\n # [1, 1, 0, 1, 1],\n # [1, 1, 1, 0, 1],\n # [1, 1, 1, 1, 0]\n # ]\n vertices =[]\n edges = []\n graph.each_with_index do |v,s|\n vertices.push(Vertex.new(v,s))\n v.each_with_index do |w, e|\n edges.push(Edge.new(s,e,w))\n end\n end\n source = 4\n p bellmanFord(vertices,edges,source)\nend",
"def breadth_first\n return do_breadth_first( [Node.new(@start)], Set.new, @dest)\n end",
"def test_branch_chain\n #puts \"---------------test_branch_chain-----------------\"\n\n t1= t2 = t11 = t12 = t21 = t22 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do\n b.chain do\n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n b.chain do\n t21 = b.add(Thing21.new)\n t22 = b.add(Thing22.new)\n end\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12,t21,t22])\n assert r.include? [t1,t11]\n assert r.include? [t11,t12]\n assert r.include? [t12,t2]\n\n assert r.include? [t1,t21]\n assert r.include? [t21,t22]\n assert r.include? [t22,t2]\n\n assert_equal 6, r.size\n end",
"def nodes_breadthfirst(node = self.root, &block)\n @nodes = []\n iterate_breadthfirst(node, &block)\n ensure\n @nodes = nil\n end",
"def bfs_search(root)\n queue = []\n\n root.marked = true\n queue.push(root)\n\n while queue.length != 0\n current = queue.shift\n visit(current)\n\n current.adjacent.each do |node|\n if !node.marked\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def bfs( start, &block )\n start.distance = 0\n start.predecessor = nil\n start.gray!\n vq = Queue.new()\n vq.enqueue(start)\n while vq.size > 0\n current = vq.dequeue()\n current.get_connections.each do |nbr|\n if nbr.white?\n nbr.gray!\n nbr.distance = current.distance + 1\n nbr.predecessor = current\n vq.enqueue(nbr)\n end\n end\n current.black!\n yield current if block_given?\n end\n # clean up vertices attributes set during bfs\n @vertices.keys.each do |key|\n @vertices[key].distance = nil\n @vertices[key].predecessor = nil\n @vertices[key].color = nil\n end\n end",
"def test_gets_all_nodes_and_k\n @k = @bc.find_k\n @num_nodes = @bc.num_nodes\n assert_equal @num_nodes, 200_000\n assert_equal @k, 6118\n end",
"def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end",
"def test_ce_deBoer_2\n NArray.srand(567) # must use NArray's generator, not Ruby's\n\n # Cost matrix\n n = 5\n c = NArray[[0,1,3,5,6],\n [1,0,3,6,5],\n [3,3,0,2,2],\n [5,6,2,0,2],\n [6,5,2,2,0]]\n\n mp = CrossEntropy::MatrixProblem.new\n mp.pr = NArray.float(2, n).fill!(0.5)\n mp.pr[true,0] = NArray[0.0,1.0] # put vertex 0 in subset 1\n mp.num_samples = 50\n mp.num_elite = 5\n mp.max_iters = 10\n smooth = 0.4\n\n max_cut_score = proc do |sample|\n weight = 0\n for i in 0...n\n for j in 0...n\n weight += c[j,i] if sample[i] < sample[j]\n end\n end\n -weight # to be minimized\n end\n best_cut = NArray[1,1,0,0,0]\n assert_equal(-15, max_cut_score.call(NArray[1,0,0,0,0]))\n assert_equal(-28, max_cut_score.call(best_cut))\n\n mp.to_score_sample(&max_cut_score)\n\n mp.to_update do |pr_iter|\n smooth*pr_iter + (1 - smooth)*mp.pr\n end\n\n mp.for_stop_decision do\n #p mp.pr\n mp.num_iters >= mp.max_iters\n end\n\n mp.solve\n\n if best_cut != mp.most_likely_solution\n warn \"expected #{best_cut}; found #{mp.most_likely_solution}\" \n end\n assert mp.num_iters <= mp.max_iters\n end",
"def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend",
"def bread_first_search(first)\n puts sprintf(\"%-25s %s\", \"Queue: [ bottom - top ]\", \"Visited list\")\n enqueue(first)\n insert_visited(first)\n print\n\n while !queue.empty?\n element = dequeue # => |V|\n @source.fetch(element).each do |s| \n unless @visited.include?(s) # => |E|\n enqueue(s)\n @T.push([element,s]) \n insert_visited(s) \n end\n end\n print\n end\n # spanning tree\n p @T\n end",
"def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend",
"def bsearch(trueside,falseside,tol=10**(-9))\r\n ok,ng=trueside,falseside\r\n div=tol.is_a?(Integer) ? 2 : 2.0\r\n while((ok-ng).abs>tol) do\r\n mid=(ng+ok)/div\r\n if(yield(mid))\r\n ok=mid\r\n else\r\n ng=mid\r\n end\r\n end\r\n return ok\r\nend",
"def check_delta3\n bk = nil\n bd = nil\n tbk = nil\n tbd = nil\n (0...2 * @nvertex).each do |b|\n next unless @blossom_parent[b].nil? && @label[b] == MWMGeneral::LBL_S\n blossom_leaves(b).each do |v|\n @neighb_end[v].each do |p|\n k = p / 2 # Note: floor division\n w = @endpoint[p]\n unless @in_blossom[w] != b &&\n @label[@in_blossom[w]] == MWMGeneral::LBL_S\n next\n end\n d = slack(k)\n if bk.nil? || d < bd\n bk = k\n bd = d\n end\n end\n end\n next if @best_edge[b].nil?\n i, j = @edges[@best_edge[b]].to_a\n unless @in_blossom.values_at(i, j).include?(b)\n raise 'Assertion failed'\n end\n unless @in_blossom[i] != b || @in_blossom[j] != b\n raise 'Assertion failed'\n end\n unless @label[@in_blossom[i]] == MWMGeneral::LBL_S &&\n @label[@in_blossom[j]] == MWMGeneral::LBL_S\n raise 'Assertion failed'\n end\n if tbk.nil? || slack(@best_edge[b]) < tbd\n tbk = @best_edge[b]\n tbd = slack(@best_edge[b])\n end\n end\n unless bd == tbd\n raise 'Assertion failed'\n end\n end",
"def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n\tnext unless @graph[from]\n\t@graph[from].each_key do |to|\n\t unless visited[to]\n\t visited[to] = true\n\t distance[to] = distance[from] + 1\n\t predecessor[to] = from\n\t queue.push(to)\n\t end\n\tend\n end\n return distance, predecessor\n end",
"def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n next unless @graph[from]\n @graph[from].each_key do |to|\n unless visited[to]\n visited[to] = true\n distance[to] = distance[from] + 1\n predecessor[to] = from\n queue.push(to)\n end\n end\n end\n return distance, predecessor\n end",
"def bft(&block)\n queue = Queue.new\n \n # Set all nodes to not enqueued\n self.each do |node|\n node.enqueued = false\n end\n\n queue.push(self) \n self.enqueued = true\n\n while(queue.size > 0)\n # Get next node in the queue\n node = queue.pop\n \n # Pass node off to block\n block.call(node)\n\n # Enqueue all children nodes\n node.child_array.each do |child|\n if !child.enqueued\n queue.push(child)\n child.enqueued = true\n end\n end\n\n end #while\n end",
"def test_branch\n #puts \"---------------test_branch-----------------\"\n t1= nil\n t2 = nil\n t11 = nil\n t12 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12])\n assert_equal 4, r.size\n assert r.include? [t1,t11]\n assert r.include? [t1,t12]\n assert r.include? [t11,t2]\n assert r.include? [t12,t2]\n end",
"def test_step_on_examples\n assert_equal([], @small_dfa.step(0,'b'))\n @small_dfa.each_state do |s|\n s.out_edges.each do |e|\n assert_equal([e.target], @small_dfa.step(s,e.symbol))\n end\n end\n\n assert_equal([], @small_nfa.step(0, 'b'))\n assert_equal(@small_nfa.ith_states(1), @small_nfa.step(0, 'a'))\n assert_equal(@small_nfa.ith_states(2,3), @small_nfa.step(1, 'b'))\n assert_equal(@small_nfa.ith_states(1), @small_nfa.step(1, nil))\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n visited = Set.new()\n\n starting_node.neighbors.each do |neighb_nodes|\n\n return queue.first.value if queue.first.value == target_value\n\n visited.add(queue.shift) \n\n queue.push(neighb_nodes) unless visited.include?(neighb_nodes)\n \n end\n nil\nend",
"def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n checked_nodes = Set.new\n\n until queue.empty?\n current = queue.shift\n unless checked_nodes.include?(current)\n checked_nodes.add(current)\n return current if current.value == target_value\n queue += current.neighbors\n end\n end\n nil\nend",
"def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end",
"def breadth_first_search?(graph, start, goal)\n visited = Hash.new(false)\n queue = Queue.new\n queue.push(start)\n visited[start] = true\n until queue.empty? do\n node = queue.pop\n return true if node == goal\n add_to_queue(graph, queue, node, visited)\n end\n false\n end",
"def initialize(height, branching_factor, approx)\n @height = height #get inputs\n @height_count = height\n @branching_factor = branching_factor#get inputs\n @approx = approx#get inputs\n @node_array = []#initialise empty array of nodes\n @node_type = true # set to build daughters first\n get_t_value#get random t_value\n @root_node = RootNode.new\n @root_node.t_value = @t_value # give starting t value to buid tree from\n @node_array << @root_node# to be checked in further building of tree\n build_connecting_nodes(@root_node,@branching_factor)#build first daughters\n @node_type = !@node_type #change to enter next values of interior nodes\n @height_count = @height_count-1 #one layer done\n build_rest_of_tree()\n end",
"def bfs(start_node_num)\n node = find_node(start_node_num)\n _clear_visited\n ret_list = [node.value]\n # Your code here\n q = Queue.new\n q << node\n node.visited = true\n\n until q.empty?\n current = q.pop\n current.edges.each do |edge|\n next if edge.node_to.visited\n q << edge.node_to\n edge.node_to.visited = true\n ret_list << edge.node_to.value\n end\n end\n\n return ret_list\n end",
"def testInitialize_2SW_1NE_depth2\n ps = [UniquePoint3.new(0,0,0), UniquePoint3.new(3,3,0), UniquePoint3.new(8,8,8)]\n q = QuadTreeAccelerator.new(ps)\n assert_equal(\n\"(0,[[0,0,0],[8,8,8]],[])\n SW\n (1,[[0,0,0],[4.0,4.0,8]],[])\n SW\n (2,[[0,0,0],[2.0,2.0,8]],[[0,0,0]])\n NE\n (2,[[2.0,2.0,0],[4.0,4.0,8]],[[3,3,0]])\n NE\n (1,[[4.0,4.0,0],[8,8,8]],[[8,8,8]])\n\", q.to_s)\n end",
"def bfs(root, target)\n queue = []\n queue << root\n\n until queue.empty?\n current = queue.shift\n\n next if current.nil?\n return true if current.val == target\n\n queue << current.left\n queue << current.right\n end\n\n return false\nend",
"def bst?(node)\n result = true\n hopefully_sorted = inorder_traversal_node(node)\n hopefully_sorted.each_with_index do |item, index|\n break if hopefully_sorted[index + 1].nil?\n if hopefully_sorted[index] > hopefully_sorted[index + 1]\n return false\n end\n end\n true\nend",
"def bfs\r\n q = Queue.new\r\n visited = Set.new\r\n\r\n q << [0, panda]\r\n visited << panda\r\n\r\n until q.empty?\r\n level, current_panda = q.shift\r\n unvisited = @members[current_panda].select { |v| !visited.include? v }\r\n unvisited.each do |v|\r\n q << [level + 1, v]\r\n visited << v\r\n end\r\n end\r\n end",
"def breadthTraversal(path, parent = nil)\n\t@jobs.push Job.new(path, parent)\n\n\twhile not @jobs.empty?\n\t\tbtraverse(@jobs.pop)\n\tend\nend",
"def test_neighbour_count\n # Empty\n @game.state=[[0,0,0],[0,0,0],[0,0,0]]\n assert_equal 0,@game.neighbour_count(0,0)\n assert_equal 0,@game.neighbour_count(1,1)\n\n # One cell, check all neighbours, check proper edge wrapping\n @game.state=[[0,0,0],[0,1,0],[0,0,0]]\n assert_equal 1,@game.neighbour_count(0,2),'0,2'\n assert_equal 1,@game.neighbour_count(0,0),'0,0'\n assert_equal 1,@game.neighbour_count(0,1),'0,1'\n assert_equal 1,@game.neighbour_count(1,0),'1,0'\n assert_equal 0,@game.neighbour_count(1,1),'1,1' # Don't count self\n assert_equal 1,@game.neighbour_count(1,2),'1,2'\n assert_equal 1,@game.neighbour_count(2,0),'2,0'\n assert_equal 1,@game.neighbour_count(2,1),'2,1'\n assert_equal 1,@game.neighbour_count(2,2),'2,2'\n\n # Eight cells, check all neighbours, check proper edge wrapping\n @game.state=[[1,1,1],[1,0,1],[1,1,1]]\n assert_equal 7,@game.neighbour_count(0,2),'0,2'\n assert_equal 7,@game.neighbour_count(0,0),'0,0'\n assert_equal 7,@game.neighbour_count(0,1),'0,1'\n assert_equal 7,@game.neighbour_count(1,0),'1,0'\n assert_equal 8,@game.neighbour_count(1,1),'1,1' # Only cell with 8\n assert_equal 7,@game.neighbour_count(1,2),'1,2'\n assert_equal 7,@game.neighbour_count(2,0),'2,0'\n assert_equal 7,@game.neighbour_count(2,1),'2,1'\n assert_equal 7,@game.neighbour_count(2,2),'2,2'\n end",
"def breadth_first(node, target)\n # Setup\n queue = Queue.new\n queue.enqueue(node)\n # While queue exists\n while queue.elements?\n # Pop bottom off\n current_node = queue.dequeue\n # Check if it is target or nil\n return 'Could not locate your payload :(' if current_node.nil?\n return 'Found your target' if current_node.payload == target\n # Otherwise add its children to\n # back of line for checking\n add_kids_to_queue(current_node, queue)\n end\nend",
"def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end",
"def path_finder \n until queue.empty? \n current_node = queue.shift()\n generate_neighbours(current_node)\n current_node.neighbour_nodes.each do |neighbour|\n track_visited(current_node, neighbour)\n correct_node?(neighbour) ? (return neighbour.visited) : (queue << neighbour)\n end\n end\n end",
"def test_05\n @dg = DiGraph.new([0,7],[1,9],[1,4],[7,4],[7,0],[7,9],[3,7],[9,4],[9,7],[9,9],[4,1],[4,4],[4,7])\n @paths = Hash.new\n @paths[0] = [7]\n @paths[1] = [9,4]\n @paths[7] = [4,0,9]\n @paths[3] = [7]\n @paths[9] = [4,7,9]\n @paths[4] = [1,4,7]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_05 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end",
"def bfs(graph, starting_point)\n q = Queue.new()\n q.enq(starting_point)\n visited = [] \n loop do \n node = q.deq\n visited.push(node) unless visited.include?(node) \n graph.values[node].each{ |x| q.enq(x) }\n break if visited.length == graph.length\n end \n visited\n end",
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end",
"def test_find_stack_overflow\n skip # because it takes *forever*\n @starting_point = MM::Ratio.new(1,1)\n @search = MM::Search.new(@starting_point)\n @search.delta = 0.001\n @search.adjacent_points_function = ->(current) {\n [MM::Ratio.new(1,1), MM::Ratio.new(-1,1)].map {|m| m + current}\n }\n goal = MM::Ratio.new(9000,1)\n @search.cost_function = ->(x) {\n (x - goal).abs\n }\n assert_equal goal, @search.find\n puts @search.iterations\n end",
"def bfs(target_pos) #this is called on the root node \n tar_x, tar_y = target_pos \n\n arr = [self]\n\n until arr.empty?\n current_check = arr.shift \n return current_check if current_check.root_node == target_pos\n arr.concat(current_check.children)\n end\n nil\n end",
"def test_groebner_basis_coeff_01\n x, y, z = @P.vars('xyz')\n\n f1 = x**2 + y**2 + z**2 - 1\n f2 = x**2 + z**2 - y\n f3 = x - z\n\n g = x**3 + y**3 + z**3\n q, r = g.divmod_s(f1, f2, f3)\n # p q\n # p r\n assert_equal(g, q.inner_product([f1, f2, f3]) + r)\n # if g == q.inner_product([f1, f2, f3]) + r\n # puts \"Success!\"\n # else\n # puts \"Fail.\"\n # end\n end",
"def bfs(starting_node, target_value)\n visited = Set.new()\n queue = [starting_node]\n until queue.empty?\n dequeued = queue.shift\n return dequeued if dequeued.val == target_value\n visited.add(dequeued)\n dequeued.neighbors.each do |neighbor|\n queue << neighbor unless visited.include?(neighbor)\n end\n end\n nil\nend",
"def test_06\n @dg = DiGraph.new([5,9],[0,3],[3,8],[8,9],[9,0])\n @paths = Hash.new\n @paths[5] = [9]\n @paths[0] = [3]\n @paths[3] = [8]\n @paths[8] = [9]\n @paths[9] = [0]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_06 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end",
"def breadth_first_search(node, search_val = nil)\n return unless node\n visit_queue = [node]\n\n while (!visit_queue.empty?)\n node = visit_queue.shift\n node.visit\n return node if node.value == search_val\n node.connections.each do |conn|\n next if conn.marked\n conn.marked = true\n visit_queue.push(conn)\n end\n end\nend",
"def test_dfa_step_on_examples\n assert_equal(nil, @small_dfa.dfa_step(0,'b'))\n @small_dfa.each_state do |s|\n s.out_edges.each do |e|\n assert_equal(e.target, @small_dfa.dfa_step(s,e.symbol))\n end\n end\n end",
"def testInitialize_1SW_2NW_3NE_0SE_depth2\n ps = [UniquePoint3.new(0,0,0), UniquePoint3.new(1,7,2),\n UniquePoint3.new(3,5,2), UniquePoint3.new(5,7,2), UniquePoint3.new(5,5,2),\n UniquePoint3.new(7,5,2), UniquePoint3.new(8,8,8)]\n q = QuadTreeAccelerator.new(ps)\n assert_equal(\n\"(0,[[0,0,0],[8,8,8]],[])\n SW\n (1,[[0,0,0],[4.0,4.0,8]],[[0,0,0]])\n NE\n (1,[[4.0,4.0,0],[8,8,8]],[])\n SW\n (2,[[4.0,4.0,0],[6.0,6.0,8]],[[5,5,2]])\n SE\n (2,[[6.0,4.0,0],[8,6.0,8]],[[7,5,2]])\n NE\n (2,[[6.0,6.0,0],[8,8,8]],[[8,8,8]])\n NW\n (2,[[4.0,6.0,0],[6.0,8,8]],[[5,7,2]])\n NW\n (1,[[0,4.0,0],[4.0,8,8]],[])\n SE\n (2,[[2.0,4.0,0],[4.0,6.0,8]],[[3,5,2]])\n NW\n (2,[[0,6.0,0],[2.0,8,8]],[[1,7,2]])\n\", q.to_s)\n end",
"def test_ce_deBoer_1\n NArray.srand(567) # must use NArray's generator, not Ruby's\n\n n = 10\n y_true = NArray[1,1,1,1,1,0,0,0,0,0]\n\n mp = CrossEntropy::MatrixProblem.new\n mp.pr = NArray.float(2, n).fill!(0.5)\n mp.num_samples = 50\n mp.num_elite = 5\n mp.max_iters = 10\n\n mp.to_score_sample do |sample|\n y_true.eq(sample).count_false # to be minimized\n end\n\n mp.solve\n\n if y_true != mp.most_likely_solution\n warn \"expected #{y_true}; found #{mp.most_likely_solution}\" \n end\n assert mp.num_iters <= mp.max_iters\n end",
"def alg; end",
"def bfs\n bfs_queue = []\n curr = @root\n node_list = []\n while curr\n visit(curr, node_list)\n bfs_queue << curr.left if curr.left\n bfs_queue << curr.right if curr.right\n curr = bfs_queue.shift\n end\n return node_list\n end",
"def bfs(g,s)\r\n q = []\r\n dists = Hash.new(Float::INFINITY)\r\n curr = s\r\n dists[curr] = 0\r\n \r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n while q.size > 0\r\n \tprev,curr = q.shift\r\n dists[curr] = [6 + dists[prev],dists[curr]].min\r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n #prev,curr = q.shift\r\n end\r\n \r\n return dists\r\nend",
"def solve_biro_recursion\n\t\ttime do\n\t\t\tans = self.biro_recursion(@size, @size)\n\t\t\tputs \"The number of routes through a #{@size}x#{@size} grid is #{ans}.\"\n\t\tend\n\tend",
"def greedy1_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n # Test each site ...\n src_partition.sites.each do |site|\n\n simulation_result_below_bound = {}\n simulation_result_above_bound = {}\n # ... in each bin ...\n self.each_with_index do |bin, bin_index|\n target_partition = bin.list[src_partition.name]\n if target_partition.nil?\n # Creating a new partition is more costly than the worst case\n operations = @operations_worst_case + 1\n else\n # Simulate insertion of site into existing partition of current bin\n operations = target_partition.incr_add_sites!([site], simulate = true)\n end\n # Check if bin.size is smaller than lower_bound. Save simulation_result accordingly to prefer addition below lower_bound.\n if bin.update_size!.size < @operations_lower_bound\n simulation_result_below_bound.merge!({operations => bin_index})\n else\n simulation_result_above_bound.merge!({operations => bin_index})\n end\n\n end\n\n # Insert at lowest operation cost\n best = if simulation_result_below_bound.empty?\n simulation_result_above_bound.min_by { |operations, bin_index| operations }\n else\n simulation_result_below_bound.min_by { |operations, bin_index| operations }\n end\n target_partition = @list[best[1]].list[src_partition.name]\n if target_partition.nil?\n @list[best[1]].add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\n end",
"def solve_bfs(initial, final)\n\tunvisited = [initial]\n\tvisited = Set.new unvisited\n\n\twhile not unvisited.empty?\n\t\tc = unvisited[0]\n\t\tunvisited.delete_at 0\n\n\t\treturn c.n_moves if c.eql? final\n\t\tneighbours = c.moves.select { |x| not visited.include? x }\n\t\tunvisited.concat(neighbours)\n\t\tvisited.merge neighbours\n\tend\n\tNO_SOLUTION\nend",
"def test_HEURISTIC_20\n path=\"/home/miro/NetBeansProjects/Knapsack/test/\"\n\n p=Solver.new\n\n p.read_problem(path+\"input3\")\n\n assert_equal(1979, p.heuristic)\n\n p=Solver.new\n p.read_problem(path+\"input4\")\n\n assert_equal(2168, p.heuristic)\n\n p=Solver.new\n p.read_problem(path+\"input5\")\n\n assert_equal(2516, p.heuristic)\n\n\n\n end",
"def breadth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue << current_node.left_child if not current_node.left_child.nil?\r\n queue << current_node.right_child if not current_node.right_child.nil?\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end",
"def is_bst?(node)\nend",
"def step\n any_independent = false\n net.edges.each do |e|\n a, b = e.source, e.target\n intersect = (@net.adjacent_either(a, b) & @net.verts_on_paths(a, b)).extend(PowerSet)\n \n # Is |Aab ^ Uab| > n? \n if intersect.length <= n\n next\n else\n # Are a and b independent conditioned on any subsets of Aab ^ Uab of cardinality n+1?\n valid_intersects = intersect.power_set.select {|s| s.length == n+1}.reject { |subset| subset.include?(a) || subset.include?(b) }\n if valid_intersects.any? { |subset|\n print \"Testing independence between #{a.name} and #{b.name}, conditioning on #{(subset.any? ? subset.map(&:name).join(', ') : 'nothing') + '...'}\"\n print (coindependent?(p_value, a, b, *subset) ? \"[+]\\n\" : \"[-]\\n\")\n coindependent?(p_value, a, b, *subset)\n }\n @net = remove_edge(net, e)\n net.edges.each do |e|\n puts \"#{e.source.name} => #{e.target.name}\"\n end\n any_independent = true\n end\n end\n end\n @n += 1\n any_independent\n end",
"def test_num_neighbors_zero\r\n\t\tassert_equal 0, @t.num_neighbors\r\n\tend"
] |
[
"0.6748863",
"0.6638496",
"0.6524973",
"0.64008266",
"0.6240808",
"0.62361646",
"0.6219844",
"0.6144744",
"0.61364985",
"0.61242646",
"0.60998636",
"0.6016119",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.60131943",
"0.5943237",
"0.59220093",
"0.5825931",
"0.5814181",
"0.5797362",
"0.5772252",
"0.5759461",
"0.5744695",
"0.57287425",
"0.5711592",
"0.5683878",
"0.5669265",
"0.56650543",
"0.5656908",
"0.5621125",
"0.56195974",
"0.56134194",
"0.5612439",
"0.55978346",
"0.5581594",
"0.5566391",
"0.5552575",
"0.55413",
"0.55409443",
"0.5534096",
"0.55323225",
"0.55163354",
"0.5510308",
"0.54954165",
"0.5488503",
"0.547128",
"0.5437028",
"0.54311675",
"0.54287595",
"0.5422165",
"0.5420785",
"0.5415936",
"0.53992194",
"0.5397188",
"0.53772485",
"0.5375534",
"0.5370281",
"0.5369152",
"0.5361702",
"0.53600883",
"0.53586155",
"0.5340645",
"0.5338307",
"0.5338057",
"0.5328076",
"0.53221923",
"0.53148025",
"0.5310378",
"0.530531",
"0.52977735",
"0.5258036",
"0.52516204",
"0.5250631",
"0.5249528",
"0.52468485",
"0.5242446",
"0.52349156",
"0.5230268",
"0.5221054",
"0.5217072",
"0.5205812",
"0.5203914",
"0.5200728",
"0.5199835",
"0.51954454",
"0.51912296"
] |
0.66878647
|
1
|
Test the breadth for each
|
def test_breadth_each
j = Tree::TreeNode.new("j")
f = Tree::TreeNode.new("f")
k = Tree::TreeNode.new("k")
a = Tree::TreeNode.new("a")
d = Tree::TreeNode.new("d")
h = Tree::TreeNode.new("h")
z = Tree::TreeNode.new("z")
# The expected order of response
expected_array = [j,
f, k,
a, h, z,
d]
# Create the following Tree
# j <-- level 0 (Root)
# / \
# f k <-- level 1
# / \ \
# a h z <-- level 2
# \
# d <-- level 3
j << f << a << d
f << h
j << k << z
# Create the response
result_array = Array.new
j.breadth_each { |node| result_array << node.detached_copy }
expected_array.each_index do |i|
assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_breadth\n assert_equal(1, @root.breadth, \"A single node's breadth is 1\")\n\n @root << @child1\n assert_equal(1, @root.breadth, \"This should be of breadth 1\")\n\n @root << @child2\n assert_equal(2, @child1.breadth, \"This should be of breadth 2\")\n assert_equal(2, @child2.breadth, \"This should be of breadth 2\")\n\n @root << @child3\n assert_equal(3, @child1.breadth, \"This should be of breadth 3\")\n assert_equal(3, @child2.breadth, \"This should be of breadth 3\")\n\n @child3 << @child4\n assert_equal(1, @child4.breadth, \"This should be of breadth 1\")\n end",
"def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend",
"def bfs\n\n\n end",
"def breadth_first(value)\n\tend",
"def bfs\n\n end",
"def bfs\n # raise NotImplementedError\n end",
"def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end",
"def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end",
"def test_branch_chain2\n #puts \"---------------test_branch_chain2-----------------\"\n\n t1= t2 = t11 = t12 = t21 = t23 = t31 = t32 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do\n b.chain do\n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n b.chain do\n b.branch do\n t21 = b.add(Thing21.new)\n b.chain do\n t31 = b.add(Thing31.new)\n t32 = b.add(Thing32.new)\n end\n end\n t23 = b.add(Thing23.new)\n end\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12,t21,t23,t31,t32])\n assert r.include? [t1,t11]\n assert r.include? [t1,t21]\n assert r.include? [t1,t31]\n\n assert r.include? [t11,t12]\n assert r.include? [t12,t2]\n\n assert r.include? [t21,t23]\n assert r.include? [t23,t2]\n\n assert r.include? [t31,t32]\n assert r.include? [t32,t23]\n\n assert_equal 9, r.size\n end",
"def test_branch_chain\n #puts \"---------------test_branch_chain-----------------\"\n\n t1= t2 = t11 = t12 = t21 = t22 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do\n b.chain do\n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n b.chain do\n t21 = b.add(Thing21.new)\n t22 = b.add(Thing22.new)\n end\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12,t21,t22])\n assert r.include? [t1,t11]\n assert r.include? [t11,t12]\n assert r.include? [t12,t2]\n\n assert r.include? [t1,t21]\n assert r.include? [t21,t22]\n assert r.include? [t22,t2]\n\n assert_equal 6, r.size\n end",
"def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= 1\n queue.push(neighbor) if @in_degrees[neighbor].zero?\n end\n end\n\n visited.size == @num_courses ? visited : []\n end",
"def BFT_iterative(root)\n print '[\"I\", \"O\", \"H\", \"L\", \"R\", \"T\", \"M\", \"A\", \"G\"]' + \"\\n\"\n if root == nil\n return\n end\n q = Queue.new\n q.enqueue(root)\n\n while !q.empty?\n root = q.dequeue # I\n print(\"#{root.value}\\n\") \n if !root.left.nil?\n q.enqueue(root.left)\n end\n if !root.left.nil?\n q.enqueue(root.right)\n end\n end\n end",
"def test_branch\n #puts \"---------------test_branch-----------------\"\n t1= nil\n t2 = nil\n t11 = nil\n t12 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12])\n assert_equal 4, r.size\n assert r.include? [t1,t11]\n assert r.include? [t1,t12]\n assert r.include? [t11,t2]\n assert r.include? [t12,t2]\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def test_children\n #puts \"---------------test_children-----------------\"\n t= {}\n\n batch11 = MyResource.new :batch11\n batch12 = MyResource.new :batch12\n batch21 = MyResource.new :batch21\n batch22 = MyResource.new :batch22\n pos1 = MyResource.new :pos1, [ batch11, batch12 ]\n pos2 = MyResource.new :pos2, [ batch21, batch22 ]\n order = MyResource.new :order, [pos1, pos2]\n\n GraphBuilder::Builder.build do |b|\n t[:order] = [ b.add(Thing0.new(order)) ]\n \n b.children do |pos|\n t[pos.name] = b.add Thing1.new(pos)\n b.children do |batch|\n b1 = b.add Thing11.new(batch)\n b2 = b.add Thing12.new(batch)\n t[batch.name] = [b1, b2]\n end\n end\n t[:order] << b.add( Thing2.new(order))\n end\n\n r = Thing.links(t.values.flatten)\n assert_instance_of Thing0, t[:order].first\n assert_instance_of Thing2, t[:order].last\n assert_instance_of Thing1, t[:pos1]\n assert_instance_of Thing1, t[:pos2]\n assert_instance_of Thing11, t[:batch11].first\n assert_instance_of Thing12, t[:batch12].last\n assert_instance_of Thing11, t[:batch21].first\n assert_instance_of Thing12, t[:batch22].last\n\n assert r.include? [t[:order].first,t[:pos1]]\n assert r.include? [t[:order].first,t[:pos2]]\n assert r.include? [t[:pos1],t[:batch11].first]\n assert r.include? [t[:pos1],t[:batch12].first]\n assert r.include? [t[:pos2],t[:batch21].first]\n assert r.include? [t[:pos2],t[:batch22].first]\n assert r.include? [t[:batch11].first,t[:batch11].last]\n assert r.include? [t[:batch12].first,t[:batch12].last]\n assert r.include? [t[:batch21].first,t[:batch21].last]\n assert r.include? [t[:batch22].first,t[:batch22].last]\n assert r.include? [t[:batch11].last,t[:order].last]\n assert r.include? [t[:batch12].last,t[:order].last]\n assert r.include? [t[:batch21].last,t[:order].last]\n assert r.include? [t[:batch22].last,t[:order].last]\n\n assert_equal 14, r.size\n end",
"def bfs_for(coords, current_node = @tree, queue = [], hit_squares = [], benchmark = false)\n\t\tif is_current_square_match?(coords, current_node)\n\t\t\tmatch_found(coords, current_node, benchmark)\n\t\telse\n\t\t\thit_squares << get_coords_from_node(current_node)\n\t\t\tcurrent_node.children.each {|child| queue.unshift(child) unless hit_squares.include?(get_coords_from_node(child))} if current_node.children\n\t\t\tnext_node = queue.pop\n\t\t\tnext_node.nil? ? not_found(coords, benchmark) : bfs_for(coords, next_node, queue, hit_squares, benchmark) \n\t\tend\n\tend",
"def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend",
"def test_bfs(tree, location, expect_match = true)\n puts \"\\n-----------------------------------------------------------------\\n \"\n puts \"Testing bfs method...\"\n puts \"\\nInitial location: Tree Root = [#{tree.root.location.to_s}]\\n \"\n node_match = tree.bfs(location)\n results_match = true\n if expect_match\n if node_match.nil?\n results_match = false\n else\n puts \"Node match found for [#{location[0]}, #{location[1]}]\"\n node_match.show_stats\n results_match = false unless node_match.location == location\n end\n else\n puts \"No match found\"\n results_match = false unless node_match.nil?\n end\n puts \">>>>>> ERROR <<<<<\" unless results_match\n puts \"\\n-----------------------------------------------------------------\\n \"\nend",
"def bfs(tree, value)\n q = MyQueue.new\n q.enqueue(tree)\n current_tree = q.dequeue() #need to do something when i dequeue \n \n while current_tree != nil\n puts current_tree.payload\n\n if current_tree.payload != value\n current_tree.children.each do |leaf|\n q.enqueue(leaf)\n end\n else\n q = MyQueue.new\n end\n current_tree = q.dequeue()\n end\nend",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs(starting_node, target_value)\n return starting_node if starting_node.value == target_value\n queue = [starting_node]\n until queue.empty?\n queue += starting_node.neighbors\n queue.each { |neighbor| bfs(neighbor, tar) }\n end\n nil\nend",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def breadth_first\n return do_breadth_first( [Node.new(@start)], Set.new, @dest)\n end",
"def bfs\r\n q = Queue.new\r\n visited = Set.new\r\n\r\n q << [0, panda]\r\n visited << panda\r\n\r\n until q.empty?\r\n level, current_panda = q.shift\r\n unvisited = @members[current_panda].select { |v| !visited.include? v }\r\n unvisited.each do |v|\r\n q << [level + 1, v]\r\n visited << v\r\n end\r\n end\r\n end",
"def nodes_breadthfirst(node = self.root, &block)\n @nodes = []\n iterate_breadthfirst(node, &block)\n ensure\n @nodes = nil\n end",
"def each_bfs (option_hash={:full_traverse=>true})\n def adjust_context context, dir\n con = context.dup\n case dir\n when 0 then con[:y] += 1\n when 1 then con[:x] += 1\n when 2 then con[:y] -= 1\n when 3 then con[:x] -= 1\n end\n return con\n end\n color_list, white_list = [], []\n full_traverse = option_hash[:full_traverse] \n yield_x_range, yield_y_range = option_hash[:yield_range]\n\n # white list contains data to yield and process each pass.\n white_list << [self, {:x=>0, :y=>0}]\n color_list << self\n\n # while we still have something to act upon process it.\n # And yield the result to our block of code.\n while !white_list.empty?\n r, context = white_list.shift()\n\n yield(r, context) if yield_x_range == nil || yield_y_range == nil || (yield_x_range === context[:x] && yield_y_range === context[:y])\n\n r.each_dir do |e| \n next if full_traverse == false && (e.flags_state.is_set(:soft_door) || e.flags_state.is_set(:closed))\n if e.towards_room.gri == nil\n e.do_delete\n next\n end\n if !color_list.include?(e.towards_room.gri)\n white_list << [e.towards_room.gri, adjust_context(context, e.direction)]\n color_list << e.towards_room.gri \n end\n end\n end\n return nil\n end",
"def bst?(node)\n result = true\n hopefully_sorted = inorder_traversal_node(node)\n hopefully_sorted.each_with_index do |item, index|\n break if hopefully_sorted[index + 1].nil?\n if hopefully_sorted[index] > hopefully_sorted[index + 1]\n return false\n end\n end\n true\nend",
"def check_delta3\n bk = nil\n bd = nil\n tbk = nil\n tbd = nil\n (0...2 * @nvertex).each do |b|\n next unless @blossom_parent[b].nil? && @label[b] == MWMGeneral::LBL_S\n blossom_leaves(b).each do |v|\n @neighb_end[v].each do |p|\n k = p / 2 # Note: floor division\n w = @endpoint[p]\n unless @in_blossom[w] != b &&\n @label[@in_blossom[w]] == MWMGeneral::LBL_S\n next\n end\n d = slack(k)\n if bk.nil? || d < bd\n bk = k\n bd = d\n end\n end\n end\n next if @best_edge[b].nil?\n i, j = @edges[@best_edge[b]].to_a\n unless @in_blossom.values_at(i, j).include?(b)\n raise 'Assertion failed'\n end\n unless @in_blossom[i] != b || @in_blossom[j] != b\n raise 'Assertion failed'\n end\n unless @label[@in_blossom[i]] == MWMGeneral::LBL_S &&\n @label[@in_blossom[j]] == MWMGeneral::LBL_S\n raise 'Assertion failed'\n end\n if tbk.nil? || slack(@best_edge[b]) < tbd\n tbk = @best_edge[b]\n tbd = slack(@best_edge[b])\n end\n end\n unless bd == tbd\n raise 'Assertion failed'\n end\n end",
"def test\n puts 'Building Graph for tests...'\n # Simple graph\n #\n # First\n # / \\\n # second third\n # / | | \\\n # fourth fifth goal sixth\n #\n # Construct graph\n first = GraphNode.new 'First'\n second = GraphNode.new 'Second'\n third = GraphNode.new 'Third'\n fourth = GraphNode.new 'Fourth'\n fifth = GraphNode.new 'Fifth'\n sixth = GraphNode.new 'Sixth'\n goal = GraphNode.new 'Goal'\n\n first.connect second\n first.connect third\n\n second.connect first\n second.connect fourth\n second.connect fifth\n\n third.connect first\n third.connect goal\n third.connect sixth\n\n fourth.connect second\n fifth.connect second\n\n goal.connect third\n sixth.connect third\n\n # Perform tests\n puts \"Testing from root node 'First'\"\n puts(bfs(first) { |node| puts ' ' + node })\n\n puts \"Testing from second node 'Second'\"\n puts(bfs(second) { |node| puts ' ' + node })\nend",
"def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end",
"def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend",
"def test_grid\n t = TreeShape.new(8)\n count = 0\n t.grid.each_index do |xi|\n t.grid[xi].each_index do |yi|\n count += 1\n end\n end\n assert_equal(count, t.height * t.width)\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def bfs_search(root)\n queue = []\n\n root.marked = true\n queue.push(root)\n\n while queue.length != 0\n current = queue.shift\n visit(current)\n\n current.adjacent.each do |node|\n if !node.marked\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def step\n any_independent = false\n net.edges.each do |e|\n a, b = e.source, e.target\n intersect = (@net.adjacent_either(a, b) & @net.verts_on_paths(a, b)).extend(PowerSet)\n \n # Is |Aab ^ Uab| > n? \n if intersect.length <= n\n next\n else\n # Are a and b independent conditioned on any subsets of Aab ^ Uab of cardinality n+1?\n valid_intersects = intersect.power_set.select {|s| s.length == n+1}.reject { |subset| subset.include?(a) || subset.include?(b) }\n if valid_intersects.any? { |subset|\n print \"Testing independence between #{a.name} and #{b.name}, conditioning on #{(subset.any? ? subset.map(&:name).join(', ') : 'nothing') + '...'}\"\n print (coindependent?(p_value, a, b, *subset) ? \"[+]\\n\" : \"[-]\\n\")\n coindependent?(p_value, a, b, *subset)\n }\n @net = remove_edge(net, e)\n net.edges.each do |e|\n puts \"#{e.source.name} => #{e.target.name}\"\n end\n any_independent = true\n end\n end\n end\n @n += 1\n any_independent\n end",
"def bfs( start, &block )\n start.distance = 0\n start.predecessor = nil\n start.gray!\n vq = Queue.new()\n vq.enqueue(start)\n while vq.size > 0\n current = vq.dequeue()\n current.get_connections.each do |nbr|\n if nbr.white?\n nbr.gray!\n nbr.distance = current.distance + 1\n nbr.predecessor = current\n vq.enqueue(nbr)\n end\n end\n current.black!\n yield current if block_given?\n end\n # clean up vertices attributes set during bfs\n @vertices.keys.each do |key|\n @vertices[key].distance = nil\n @vertices[key].predecessor = nil\n @vertices[key].color = nil\n end\n end",
"def breadth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n queue = []\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n connections.each do |i|\n if i.value == find\n answer = i\n condition = true\n elsif !visited.include?(i)\n visited.push(i)\n queue.push(i)\n end\n end\n end\n current = queue.shift\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend",
"def bfs(target_pos) #this is called on the root node \n tar_x, tar_y = target_pos \n\n arr = [self]\n\n until arr.empty?\n current_check = arr.shift \n return current_check if current_check.root_node == target_pos\n arr.concat(current_check.children)\n end\n nil\n end",
"def process(items, draw_each_step = false)\n # Put the most dense items at the top of the pile.\n sorted_pile = items.sort do |item1,item2|\n item2.density <=> item1.density\n end\n\n # Add each item to the bag\n bag = Knapsack::Bag.new(10, sorted_pile)\n sorted_pile.each_with_index do |item, ix|\n bag.consider(item)\n if draw_each_step\n Knapsack::draw_bag(bag.start, \"tree-#{ix}.png\")\n end\n end\n\n # Draw a picture...\n Knapsack::draw_bag(bag.start, \"tree.png\")\n Knapsack::draw_pile(sorted_pile, \"pile.png\")\nend",
"def test_depth=\n @br.depth = 100\n end",
"def bfs(target_value)\n child_arr = [self]\n # children.each {|child| children_arr << child }\n while child_arr.length > 0\n node_to_check = child_arr.shift\n return node_to_check if node_to_check.value == target_value\n node_to_check.children.each { |child| child_arr << child }\n end\n nil\n end",
"def bft(&block)\n queue = Queue.new\n \n # Set all nodes to not enqueued\n self.each do |node|\n node.enqueued = false\n end\n\n queue.push(self) \n self.enqueued = true\n\n while(queue.size > 0)\n # Get next node in the queue\n node = queue.pop\n \n # Pass node off to block\n block.call(node)\n\n # Enqueue all children nodes\n node.child_array.each do |child|\n if !child.enqueued\n queue.push(child)\n child.enqueued = true\n end\n end\n\n end #while\n end",
"def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end",
"def bfs(val) \n queue = [self] \n\n until queue.empty? \n if queue.first.value == val\n return queue.first\n else\n queue.concat(queue.shift.children) #you add [] + children's children\n end\n end\n nil #if noting == val\n end",
"def test_neighbour_count\n # Empty\n @game.state=[[0,0,0],[0,0,0],[0,0,0]]\n assert_equal 0,@game.neighbour_count(0,0)\n assert_equal 0,@game.neighbour_count(1,1)\n\n # One cell, check all neighbours, check proper edge wrapping\n @game.state=[[0,0,0],[0,1,0],[0,0,0]]\n assert_equal 1,@game.neighbour_count(0,2),'0,2'\n assert_equal 1,@game.neighbour_count(0,0),'0,0'\n assert_equal 1,@game.neighbour_count(0,1),'0,1'\n assert_equal 1,@game.neighbour_count(1,0),'1,0'\n assert_equal 0,@game.neighbour_count(1,1),'1,1' # Don't count self\n assert_equal 1,@game.neighbour_count(1,2),'1,2'\n assert_equal 1,@game.neighbour_count(2,0),'2,0'\n assert_equal 1,@game.neighbour_count(2,1),'2,1'\n assert_equal 1,@game.neighbour_count(2,2),'2,2'\n\n # Eight cells, check all neighbours, check proper edge wrapping\n @game.state=[[1,1,1],[1,0,1],[1,1,1]]\n assert_equal 7,@game.neighbour_count(0,2),'0,2'\n assert_equal 7,@game.neighbour_count(0,0),'0,0'\n assert_equal 7,@game.neighbour_count(0,1),'0,1'\n assert_equal 7,@game.neighbour_count(1,0),'1,0'\n assert_equal 8,@game.neighbour_count(1,1),'1,1' # Only cell with 8\n assert_equal 7,@game.neighbour_count(1,2),'1,2'\n assert_equal 7,@game.neighbour_count(2,0),'2,0'\n assert_equal 7,@game.neighbour_count(2,1),'2,1'\n assert_equal 7,@game.neighbour_count(2,2),'2,2'\n end",
"def bread_first_search(first)\n puts sprintf(\"%-25s %s\", \"Queue: [ bottom - top ]\", \"Visited list\")\n enqueue(first)\n insert_visited(first)\n print\n\n while !queue.empty?\n element = dequeue # => |V|\n @source.fetch(element).each do |s| \n unless @visited.include?(s) # => |E|\n enqueue(s)\n @T.push([element,s]) \n insert_visited(s) \n end\n end\n print\n end\n # spanning tree\n p @T\n end",
"def bfs(target_value)\n queue = []\n queue << self\n\n while queue.empty? == false\n check = queue.pop\n \n if check.value == target_value\n return check.value\n else\n queue.unshift(*check.children)\n end\n end\n \n false\n end",
"def test(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"test failed level #{l} ,inconsistent node(s) #{difference}\" if (difference.count != 0)\n end\n puts \"test complete\"\nend",
"def calc\n # If the searches have not started\n if breadth_first_search.visited.empty?\n # Calculate the two searches\n calc_breadth_first\n calc_dijkstra\n end\n end",
"def breadth_first(node, target)\n # Setup\n queue = Queue.new\n queue.enqueue(node)\n # While queue exists\n while queue.elements?\n # Pop bottom off\n current_node = queue.dequeue\n # Check if it is target or nil\n return 'Could not locate your payload :(' if current_node.nil?\n return 'Found your target' if current_node.payload == target\n # Otherwise add its children to\n # back of line for checking\n add_kids_to_queue(current_node, queue)\n end\nend",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end",
"def bsearch(trueside,falseside,tol=10**(-9))\r\n ok,ng=trueside,falseside\r\n div=tol.is_a?(Integer) ? 2 : 2.0\r\n while((ok-ng).abs>tol) do\r\n mid=(ng+ok)/div\r\n if(yield(mid))\r\n ok=mid\r\n else\r\n ng=mid\r\n end\r\n end\r\n return ok\r\nend",
"def test_traversal_post_2x_each_entry\n expected = [ 1, 4, 7, 6, 3, 12, 14, 10, 8 ].map {|x| x * 2}\n actual = @tree.traversal(:post, ->(x) { x * 2 })\n assert_equal expected,\n actual,\n \"actual: #{actual.inspect} should be #{expected.inspect}\"\n end",
"def bfs(root, target)\n queue = []\n queue << root\n\n until queue.empty?\n current = queue.shift\n\n next if current.nil?\n return true if current.val == target\n\n queue << current.left\n queue << current.right\n end\n\n return false\nend",
"def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n checked_nodes = Set.new\n\n until queue.empty?\n current = queue.shift\n unless checked_nodes.include?(current)\n checked_nodes.add(current)\n return current if current.value == target_value\n queue += current.neighbors\n end\n end\n nil\nend",
"def test_gets_all_nodes_and_k\n @k = @bc.find_k\n @num_nodes = @bc.num_nodes\n assert_equal @num_nodes, 200_000\n assert_equal @k, 6118\n end",
"def test_each_state_on_examples\n @examples.each do |fa|\n edges = []\n fa.each_edge {|e| edges << e}\n assert_equal(fa.edges, edges)\n end\n end",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n\tnext unless @graph[from]\n\t@graph[from].each_key do |to|\n\t unless visited[to]\n\t visited[to] = true\n\t distance[to] = distance[from] + 1\n\t predecessor[to] = from\n\t queue.push(to)\n\t end\n\tend\n end\n return distance, predecessor\n end",
"def check_delta2\n (0...@nvertex).each do |v|\n next unless @label[@in_blossom[v]] == MWMGeneral::LBL_FREE\n bd = nil\n bk = nil\n @neighb_end[v].each do |p|\n k = p / 2 # Note: floor division\n w = @endpoint[p]\n next unless @label[@in_blossom[w]] == MWMGeneral::LBL_S\n d = slack(k)\n if bk.nil? || d < bd\n bk = k\n bd = d\n end\n end\n option1 = bk.nil? && @best_edge[v].nil?\n option2 = !@best_edge[v].nil? && bd == slack(@best_edge[v])\n unless option1 || option2\n raise \"Assertion failed: Free vertex #{v}\"\n end\n end\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n visited = Set.new()\n\n starting_node.neighbors.each do |neighb_nodes|\n\n return queue.first.value if queue.first.value == target_value\n\n visited.add(queue.shift) \n\n queue.push(neighb_nodes) unless visited.include?(neighb_nodes)\n \n end\n nil\nend",
"def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end",
"def is_balanced(tree, index = 0)\n return true if tree[index].nil? || tree[index] == 0\n (find_height(tree, 2*index + 1) - find_height(tree, 2*index + 2)).abs <= 1 && is_balanced(tree, 2*index + 1) && is_balanced(tree, 2*index +2)\nend",
"def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n next unless @graph[from]\n @graph[from].each_key do |to|\n unless visited[to]\n visited[to] = true\n distance[to] = distance[from] + 1\n predecessor[to] = from\n queue.push(to)\n end\n end\n end\n return distance, predecessor\n end",
"def greedy1_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n # Test each site ...\n src_partition.sites.each do |site|\n\n simulation_result_below_bound = {}\n simulation_result_above_bound = {}\n # ... in each bin ...\n self.each_with_index do |bin, bin_index|\n target_partition = bin.list[src_partition.name]\n if target_partition.nil?\n # Creating a new partition is more costly than the worst case\n operations = @operations_worst_case + 1\n else\n # Simulate insertion of site into existing partition of current bin\n operations = target_partition.incr_add_sites!([site], simulate = true)\n end\n # Check if bin.size is smaller than lower_bound. Save simulation_result accordingly to prefer addition below lower_bound.\n if bin.update_size!.size < @operations_lower_bound\n simulation_result_below_bound.merge!({operations => bin_index})\n else\n simulation_result_above_bound.merge!({operations => bin_index})\n end\n\n end\n\n # Insert at lowest operation cost\n best = if simulation_result_below_bound.empty?\n simulation_result_above_bound.min_by { |operations, bin_index| operations }\n else\n simulation_result_below_bound.min_by { |operations, bin_index| operations }\n end\n target_partition = @list[best[1]].list[src_partition.name]\n if target_partition.nil?\n @list[best[1]].add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\n end",
"def test_ith_edge_on_examples\n @examples.each do |fa|\n edges = []\n 0.upto(fa.edge_count-1) do |i|\n edges << fa.ith_edge(i)\n end\n assert_equal(fa.edges, edges)\n end\n end",
"def bst?(node)\n min = -Float::INFINITY\n traverse_in_order(node) do |n|\n return false if n.val < min\n\n min = n.val\n end\n true\nend",
"def test_step_on_examples\n assert_equal([], @small_dfa.step(0,'b'))\n @small_dfa.each_state do |s|\n s.out_edges.each do |e|\n assert_equal([e.target], @small_dfa.step(s,e.symbol))\n end\n end\n\n assert_equal([], @small_nfa.step(0, 'b'))\n assert_equal(@small_nfa.ith_states(1), @small_nfa.step(0, 'a'))\n assert_equal(@small_nfa.ith_states(2,3), @small_nfa.step(1, 'b'))\n assert_equal(@small_nfa.ith_states(1), @small_nfa.step(1, nil))\n end",
"def is_balanced(root)\n return true if root.nil?\n left_height = depth(root.left)\n right_height = depth(root.right)\n result = (left_height - right_height).abs\n return false if result > 1\n return is_balanced(root.left) && is_balanced(root.right)\nend",
"def bck(i,j,k)\n return true if k == @w.size\n rm,cm = @b.size-1, @b[0].size-1 # row max, col max.\n return false if !(i.between?(0,rm) && j.between?(0,cm))\n return false if @b[i][j] != @w[k]\n return false if @used[i][j]\n @used[i][j] = true\n [\n [i+1,j],\n [i-1,j],\n [i,j+1],\n [i,j-1],\n ].each do |ii,jj|\n return true if bck(ii,jj,k+1)\n end\n @used[i][j] = false\n return false\nend",
"def load_factor\n total_nodes = 0.0\n index = -1\n @items.each do |item|\n index = index + 1\n if item != nil\n total_nodes = total_nodes + item.count\n end\n end\n factor = total_nodes / size\n if factor > 0.7\n resize\n end\n return factor\n end",
"def bfs(target)\n visited = {}\n @graph.keys.each { |key| visited[key] = false }\n node = @graph.keys[0]\n queue = Queue.new\n queue << node\n while !(queue.length == 0)\n visited[node] = true\n puts \"node is #{node}\"\n return node if node == target\n @graph[node].each do |nabe|\n queue << nabe unless visited[nabe] == true\n end\n node = queue.pop\n end\n end",
"def bfs(starting_node, target_value)\n visited = Set.new()\n queue = [starting_node]\n until queue.empty?\n dequeued = queue.shift\n return dequeued if dequeued.val == target_value\n visited.add(dequeued)\n dequeued.neighbors.each do |neighbor|\n queue << neighbor unless visited.include?(neighbor)\n end\n end\n nil\nend",
"def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend",
"def run_bf(items)\n\n counts = Hash.new{|h,k| h[k] = 0}\n\n items.each {|item| counts[item] += 1 }\n \n dd = items.length / 10\n \n results = []\n counts.each {|item, count|\n results << item if count > dd\n }\n \n return results\n end",
"def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end",
"def bst_sequences(root)\n\nend",
"def breadth_first_scan(root, &block)\n root = slashed(root)\n \n dirs, files = listdir(root)\n path_id = File.lstat(root).ino\n \n if seenpath = $visited[path_id]\n STDERR.puts \"*** WARNING: Already seen #{root.inspect} as #{seenpath.inspect}\".red if $verbose\n else\n $visited[path_id] = root\n \n dirs.each { |f| yield root, f }\n files.each { |f| yield root, f }\n \n for dir in dirs\n breadth_first_scan(root+dir, &block)\n end\n end\nend",
"def is_balanced?\n diff = (self.left.depth - self.right.depth).abs\n if diff <= 1\n true\n else\n false\n end\n end",
"def each_dfs\n color_list, white_list = [], []\n\n white_list << self\n color_list << self\n\n while !white_list.empty?\n r = white_list.pop()\n\n # do some code for each room found in the BFS.\n yield r\n\n r.each_dir do |e|\n if !color_list.include?(e.towards_room.gri)\n white_list << r.exit_list[i].towards_room.gri\n color_list << r.exit_list[i].towards_room.gri\n end\n end\n end\n return nil\n end",
"def bfs(v)\n curr = v\n queue = []\n distances = Hash.new(0)\n queue.push(curr)\n distances[curr] = 0\n while !queue.empty?\n curr = queue.shift\n dst = distances[curr] + 1\n if @hypernyms.include?(curr)\n queue += @hypernyms[curr]\n end\n queue.each do |v|\n \n distances[v] = dst if !distances.include?(v)\n end\n end\n distances\n end"
] |
[
"0.68890536",
"0.6702945",
"0.64721006",
"0.6361148",
"0.619658",
"0.6179271",
"0.6152221",
"0.61176646",
"0.6109527",
"0.6078409",
"0.6042431",
"0.604147",
"0.6034782",
"0.60049886",
"0.5931217",
"0.59139794",
"0.5910914",
"0.5906268",
"0.5904258",
"0.5873253",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58702934",
"0.58543485",
"0.5826357",
"0.5809268",
"0.580618",
"0.5764639",
"0.5760574",
"0.57596636",
"0.57560545",
"0.57513803",
"0.5731129",
"0.57218814",
"0.56949043",
"0.56527865",
"0.5652385",
"0.5638721",
"0.56239706",
"0.56132275",
"0.5610715",
"0.5598243",
"0.55757487",
"0.5572635",
"0.55700356",
"0.5538908",
"0.5538081",
"0.5525783",
"0.54983366",
"0.54767704",
"0.5471455",
"0.5471305",
"0.5451717",
"0.54516",
"0.54507524",
"0.5448494",
"0.5434134",
"0.5433471",
"0.5432439",
"0.5423271",
"0.54148006",
"0.54146594",
"0.54085535",
"0.54035807",
"0.5392736",
"0.53866583",
"0.5381436",
"0.5378784",
"0.5377508",
"0.5374296",
"0.5367671",
"0.5365494",
"0.5360235",
"0.5352073",
"0.5343625",
"0.53421",
"0.5339597",
"0.5339012",
"0.5336",
"0.53355545",
"0.5331554",
"0.5324257",
"0.5324119",
"0.5320746",
"0.53098327",
"0.5309187"
] |
0.7331208
|
0
|
Test the preordered_each method.
|
def test_preordered_each
j = Tree::TreeNode.new("j")
f = Tree::TreeNode.new("f")
k = Tree::TreeNode.new("k")
a = Tree::TreeNode.new("a")
d = Tree::TreeNode.new("d")
h = Tree::TreeNode.new("h")
z = Tree::TreeNode.new("z")
# The expected order of response
expected_array = [j, f, a, d, h, k, z]
# Create the following Tree
# j <-- level 0 (Root)
# / \
# f k <-- level 1
# / \ \
# a h z <-- level 2
# \
# d <-- level 3
j << f << a << d
f << h
j << k << z
result_array = []
j.preordered_each { |node| result_array << node.detached_copy}
expected_array.each_index do |i|
# Match only the names.
assert_equal(expected_array[i].name, result_array[i].name)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each(&block)\n\t\t\t@ordered.each(&block)\n\t\tend",
"def each(&block)\n @ordered_elements.each(&block)\n end",
"def each order=:preorder, &block\n # I know, I know. SGF is only preorder. Well, it's implemented, ain't it?\n # Stop complaining.\n case order\n when :preorder\n preorder @root, &block\n end\n end",
"def each_preorder(proc)\n proc.call(@value1)\n proc.call(@value2) if @type == 3\n @left.each_preorder(proc) if @left\n @mid.each_preorder(proc) if @mid\n @right.each_preorder(proc) if @type == 3 && @right\n end",
"def before_each(&block)\n @before_each_blocks << block\n end",
"def check_preorder(node, exp)\n exp.map!{|n| [n]}\n\n out = yields(:preorder, node, node)\n assert_equal_yields exp, out\n\n out = yields(:reverse_postorder, node, node)\n exp.reverse!\n assert_equal_yields exp, out\n end",
"def preorder\n yield self\n each do |child|\n unless pre_terminal?\n child.preorder {|c| yield c}\n else\n each {|c| yield c}\n end\n end\n end",
"def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end",
"def pre_order_traversal(tree=root, ordering=[])\n end",
"def test_0940_slice_before\n @@log.debug \"test_0940_slice_before starts\" if @@log.debug?\n assert_respond_to(@list, :slice_before, \"test_0940_slice_before_respond\")\n # Type check\n enum = @list.slice_before {|pers| pers.last[0] == \"B\"}\n type_check = enum.is_a? Enumerator\n assert(type_check,\"test_0940_slice_before_class\")\n # :TODO: Realistic example(s).\n @@log.debug \"test_0940_slice_before ends\" if @@log.debug?\n end",
"def preorder_traverse node, &block\n block.call(node)\n if node.children.count > 0 then\n node.children.each do |child|\n preorder_traverse(child, &block)\n end\n end\n end",
"def order\n # this method always returns MENU because\n # .each() always returns the array it iterates on\n # I'm not quite sure what you tried to do here, though\n MENU.each do |key, value| \n @items = [:pizza, :kebab]\n end\n end",
"def preorder(&block)\n yield item\n @left_subtree.preorder(&block) if @left_subtree != nil\n @right_subtree.preorder(&block) if @right_subtree != nil\n end",
"def test_order; end",
"def test_try_each_instead_of_collect_change_array\n array = [1, 2, 3]\n array = array.each { |item| item + 10 }\n #assert_equal [11, 12, 13], array\n assert_equal [1, 2, 3], array\n end",
"def skips_pre \n @skips_pre\n end",
"def pre_order(node=@root, &block)\n return if node.nil?\n yield node\n in_order(node.left, &block)\n in_order(node.right, &block)\n end",
"def preorder\n preorder_helper(@root, [])\n end",
"def before(complete = T.unsafe(nil), index = T.unsafe(nil), &block); end",
"def skips_pre #:nodoc:\n @skips_pre\n end",
"def pre_order_traversal(current_node = @root)\n @accumulator = []\n pre_order_traversal_aux(current_node)\n @accumulator\n end",
"def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end",
"def before(type=:each, &block)\n raise ArgumentError, \"invalid before-type #{type}\" unless [:each, :all].include?(type)\n type_method = \"before_#{type}\"\n remove_method(type_method) rescue nil #if method_defined?(type_method)\n define_method(type_method, &block)\n end",
"def iterator\n AlphabeticalOrderIterator.new(@collection)\n end",
"def test_page_start_for\n with_a_collection do\n assert_equal(1, @coll.page_start_for(1))\n assert_equal(11, @coll.page_start_for(2))\n end\n end",
"def ordered_list; end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def my_array_sorting_method(source)\n# This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def preproc; end",
"def _each_optional_before_sorted\n @optionals_before.each do |_, optionals|\n tmp = []\n optionals.each do |optional_index, before|\n tmp.push(\n count: before.size,\n index: optional_index,\n )\n end\n\n tmp.sort! { |a, b| b[:count] - a[:count] }.each do |item|\n yield optionals[item[:index]]\n end\n end\n\n self\n end",
"def my_array_sorting_method(source)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def processOrder\n \n end",
"def skips_pre\n @@skips_pre = true\n end",
"def is_ordered?\n # TODO Stubbed - Requires definition and implementation\n end",
"def before_tests(&block)\n @before_tests_proc = block\n end",
"def all_preorder\n inject([]) do |a, resource_template|\n a += resource_template.all_preorder\n end\n end",
"def test_ut_da10b_t1_06\n p \"Test 06\"\n # gets a list of subtasks ordered incrementally by pu_name\n subtasks = @pu.get_paginate_subtasks(1,\n \"pu_name\",\n \"asc\",\n PER_PAGE)\n\n # this list is empty\n assert_equal(PER_PAGE,subtasks.size)\n\n # this list must be sorted incrementally by row\n (1..subtasks.size - 1).each do |i|\n assert(subtasks[i].pu_name >= subtasks[i - 1].pu_name)\n end\n end",
"def test_e2111_shell_sort_increment\n verify_method :e2111_shell_sort_increment,\n :with => [\n {\n param: 3,\n predicate: Proc.new { |seq| check_shell_sort_sequence(3, seq) }\n },\n {\n param: 4,\n predicate: Proc.new { |seq| check_shell_sort_sequence(4, seq) }\n },\n {\n param: 10,\n predicate: Proc.new { |seq| check_shell_sort_sequence(10, seq) }\n },\n {\n param: 100,\n predicate: Proc.new { |seq| check_shell_sort_sequence(100, seq) }\n },\n ]\n end",
"def tsort_each_node # :yields: node\n raise NotImplementedError.new\n end",
"def pre_process(expectations, source)\n\t\tsource\n\tend",
"def preorder_print(start, traversal)\n traversal\n end",
"def each_mid(&block)\n \n end",
"def preorder\n preorder_traversal(@root, [])\n end",
"def test_all_iteration_methods_work_on_any_collection_not_just_arrays\n result = (1..3).map{ |item| item + 10}\n assert_equal [11, 12, 13], result\n\n open(\"example_file.txt\") do |file|\n upcase_lines = file.map{ |line| line.strip.upcase}\n assert_equal [\"THIS\",\"IS\", \"A\", \"TEST\"], upcase_lines\n end\n end",
"def preOrder(instruction)\n @orderMethods.preOrder(instruction)\n end",
"def assert_collection_sorted_asc(collection, symbol)\n value = collection[0]\n collection.each do |element|\n next_value = element.send(symbol)\n assert value <= next_value\n value = next_value\n end\n end",
"def tsort_each_node(&block)\n all_questions_descendants.each(&block)\n end",
"def pre_loop; end",
"def test_retuns_ordered_jobs_considering_all_dependecies\n sequence = Sequence.new()\n sequence.add(\"a =>\n b => c\n c => f\n d => a\n e => b\n f =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c d e f].include?(job))\n end\n assert sequence.ordered.index(\"f\") < sequence.ordered.index(\"c\")\n assert sequence.ordered.index(\"c\") < sequence.ordered.index(\"b\")\n assert sequence.ordered.index(\"b\") < sequence.ordered.index(\"e\")\n assert sequence.ordered.index(\"a\") < sequence.ordered.index(\"d\")\n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def preorder\n return preorder_helper(@root)\n end",
"def each(&a_proc); end",
"def nodes_preorder(node = self.root, &block)\n yield( node ) if block_given?\n nodes_preorder(node.left_child, &block) if node.has_left_child?\n nodes_preorder(node.right_child, &block) if node.has_right_child?\n end",
"def test_items\n assert_equal @order.items, @order.order_line_items\n end",
"def tsort_each_node(&block)\n self.each_key(&block)\n end",
"def each(&block)\n @succ.each(&block)\n end",
"def pre(&a_proc)\n @@pre_block = a_proc\n end",
"def preOrder(myLambda)\n if @root != nil\n method_preOrder(@root,myLambda)\n end\n end",
"def my_array_sorting_method(source)\r\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend",
"def my_array_sorting_method(source)\r\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend",
"def setup(&block)\n before(:each, &block)\n end",
"def is_ordered?\n # TODO Stubbed to always return false until ordered lists are implemented\n return false\n end",
"def test_retuns_job_in_a_specific_order_if_only_one_has_dependency\n sequence = Sequence.new()\n sequence.add(\"a =>\n b => c\n c =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c].include?(job))\n end\n assert sequence.ordered.index(\"c\") < sequence.ordered.index(\"b\")\n end",
"def generate_pre_invoice_items(tariff, pre_invoice, pre_bill, cf, user_id)\n # Should prorate\n should_prorate, prev_reading_tariff = should_prorate?(tariff)\n if should_prorate\n # Must prorate\n prorate_consumption_and_apply_tariffs('P', tariff, prev_reading_tariff, pre_invoice, pre_bill, cf, user_id)\n else\n # Current tariff only\n save_pre_invoice_items(tariff, pre_invoice, pre_bill, cf, user_id)\n end # should_prorate\n end",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_sorting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def test_it_replaces_asterisks_with_li_tags_in_ordered_lists\n ordered = OrderedListParser.new(\"1. Sushi\\n2. Barbeque\\n3. Mexican\")\n expected = \"\\t<li>Sushi</li>\\n\\t<li>Barbeque</li>\\n\\t<li>Mexican</li>\\n\"\n result = ordered.list_item_marker\n assert_equal expected, result\n end",
"def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end",
"def test_0160_each_with_index\n @@log.debug \"test_0160_each_with_index starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_index, \"test_0160_each_with_index_respond\")\n # Basic operation\n ta = []\n @list.each_with_index do |obj, ndx|\n ta << \"#{obj.first}-#{ndx}\"\n end\n assert_equal([\"Alfred-0\", \"Bob-1\", \"Charlie-2\", \"Dilbert-3\"], ta, \"test_0160_each_with_index_basic\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.each_with_index\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0160_each_with_index_enumcheck\")\nelse\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0160_each_with_index_enumenumcheck\")\nend\n @@log.debug \"test_0160_each_with_index ends\" if @@log.debug?\n end"
] |
[
"0.64636976",
"0.644502",
"0.6233939",
"0.60754436",
"0.59109217",
"0.5780458",
"0.5622207",
"0.55871916",
"0.5566852",
"0.55113477",
"0.55030495",
"0.54603636",
"0.5453088",
"0.53986776",
"0.53867394",
"0.5367764",
"0.5332064",
"0.53297645",
"0.531629",
"0.5304872",
"0.52816796",
"0.5261789",
"0.5256592",
"0.5248257",
"0.5239277",
"0.52376866",
"0.52173877",
"0.52173877",
"0.52173877",
"0.52173877",
"0.52173877",
"0.52173877",
"0.52173877",
"0.5212052",
"0.52031577",
"0.52027816",
"0.51938486",
"0.51935196",
"0.5180789",
"0.5176849",
"0.51498634",
"0.514942",
"0.51490474",
"0.51429456",
"0.5142367",
"0.5141812",
"0.513901",
"0.5137275",
"0.5127737",
"0.5127621",
"0.5126538",
"0.5123189",
"0.5110811",
"0.51080585",
"0.5085606",
"0.50813395",
"0.50813395",
"0.50813395",
"0.50813395",
"0.50813395",
"0.50813395",
"0.5077547",
"0.5075391",
"0.5070162",
"0.5064917",
"0.50641495",
"0.50569594",
"0.5054972",
"0.5049262",
"0.50459075",
"0.50459075",
"0.50266325",
"0.5026626",
"0.5019536",
"0.50160533",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.5010976",
"0.50100446",
"0.5002909",
"0.49960837"
] |
0.7615955
|
0
|
test the detached_copy method.
|
def test_detached_copy
setup_test_tree
assert(@root.has_children?, "The root should have children")
copy_of_root = @root.detached_copy
assert(!copy_of_root.has_children?, "The copy should not have children")
assert_equal(@root.name, copy_of_root.name, "The names should be equal")
# Try the same test with a child node
assert(!@child3.is_root?, "Child 3 is not a root")
assert(@child3.has_children?, "Child 3 has children")
copy_of_child3 = @child3.detached_copy
assert(copy_of_child3.is_root?, "Child 3's copy is a root")
assert(!copy_of_child3.has_children?, "Child 3's copy does not have children")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_detached_subtree_copy\n setup_test_tree\n\n assert(@root.has_children?, \"The root should have children.\")\n tree_copy = @root.detached_subtree_copy\n\n assert_equal(@root.name, tree_copy.name, \"The names should be equal.\")\n assert_not_equal(@root.object_id, tree_copy.object_id, \"Object_ids should differ.\")\n assert(tree_copy.is_root?, \"Copied root should be a root node.\")\n assert(tree_copy.has_children?, \"Copied tree should have children.\")\n assert_equal(tree_copy.children.count, @root.children.count, \"Copied tree and the original tree should have same number of children.\")\n\n assert_equal(tree_copy[0].name, @child1.name, \"The names of Child1 (original and copy) should be same.\")\n assert_not_equal(tree_copy[0].object_id, @child1.object_id, \"Child1 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[0].is_root?, \"Child1 copied should not be root.\")\n assert(!tree_copy[0].has_children?, \"Child1 copied should not have children.\")\n\n assert_equal(tree_copy[1].name, @child2.name, \"The names of Child2 (original and copy) should be same.\")\n assert_not_equal(tree_copy[1].object_id, @child2.object_id, \"Child2 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[1].is_root?, \"Child2 copied should not be root.\")\n assert(!tree_copy[1].has_children?, \"Child2 copied should not have children.\")\n\n assert_equal(tree_copy[2].name, @child3.name, \"The names of Child3 (original and copy) should be same.\")\n assert_not_equal(tree_copy[2].object_id, @child3.object_id, \"Child3 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[2].is_root?, \"Child3 copied should not be root.\")\n assert(tree_copy[2].has_children?, \"Child3 copied should have children.\")\n\n assert_equal(tree_copy[2][0].name, @child4.name, \"The names of Child4 (original and copy) should be same.\")\n assert_not_equal(tree_copy[2][0].object_id, @child4.object_id, \"Child4 Object_ids (original and copy) should differ.\")\n assert(!tree_copy[2][0].is_root?, \"Child4 copied should not be root.\")\n assert(!tree_copy[2][0].has_children?, \"Child4 copied should not have children.\")\n end",
"def test_clone_creates_a_different_object\n obj = Object.new\n copy = obj.clone\n\n assert_equal true, obj != copy\n assert_equal true, obj.object_id != copy.object_id\n end",
"def test_clone\n assert_raises(TypeError) do\n @mmap.clone\n end\n end",
"def detached?\n !attached?\n end",
"def detached?; x.nil? && y.nil?; end",
"def copy\n \n end",
"def undumpable?(object)\n !can_be_fully_dumped?(object) && !can_be_dumped_as_copy?(object)\n end",
"def copy\n self.public_send('|', 'pbcopy')\n self\n end",
"def dirty?(dump=self.dump)\n @remote_dump != dump\n end",
"def can_be_dumped_as_copy?(object)\n begin\n copy = object.class.allocate\n Marshal.dump(copy)\n true\n rescue StandardError\n false\n end\n end",
"def test_ut_diff_warning_01\n assert @diff_warning.save\n assert @diff_warning.valid?\n diff_warning_copy = DiffWarning.find(@diff_warning.id)\n assert_equal @diff_warning.diff_file_id, diff_warning_copy.diff_file_id\n assert @diff_warning.destroy\n end",
"def initialize_copy(other)\n # Think the assertion which fails if the after_initialize callback goes at the end of the method is wrong. The\n # deleted clone method called new which therefore called the after_initialize callback. It then went on to copy\n # over the attributes. But if it's copying the attributes afterwards then it hasn't finished initializing right?\n # For example in the test suite the topic model's after_initialize method sets the author_email_address to\n # test@test.com. I would have thought this would mean that all cloned models would have an author email address\n # of test@test.com. However the test_clone test method seems to test that this is not the case. As a result the\n # after_initialize callback has to be run *before* the copying of the atrributes rather than afterwards in order\n # for all tests to pass. This makes no sense to me.\n callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)\n cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)\n # CPK\n #cloned_attributes.delete(self.class.primary_key)\n self.class.primary_key.each {|key| cloned_attributes.delete(key.to_s)}\n\n @attributes = cloned_attributes\n clear_aggregation_cache\n @attributes_cache = {}\n @new_record = true\n ensure_proper_type\n\n if scope = self.class.send(:current_scoped_methods)\n create_with = scope.scope_for_create\n create_with.each { |att,value| self.send(\"#{att}=\", value) } if create_with\n end\n end",
"def test_ut_original_file_01\n assert @original_file.save\n original_file_copy = OriginalFile.find(@original_file.id)\n assert_equal @original_file.normal_result_id, original_file_copy.normal_result_id\n assert @original_file.valid?\n assert @original_file.destroy\n end",
"def should_copy?(source, target)\n return true\n return true if !File.exists?(target)\n\n source_sha = Digest::SHA1.hexdigest(File.read(source))\n target_sha = Digest::SHA1.hexdigest(File.read(target))\n \n debugger if source_sha != target_sha\n \n return true if source_sha == target_sha\n \n return false\n end",
"def test_CopyQuestionSet\n randomName = SecureRandom.hex(4)\n \n #PRECONDITION: Must be logged in\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n \n #Create an empty Question Sets\n self.CreateQuestionSetEmpty(randomName)\n \n # 1 - Go to \"Question Sets\" Tab\n Common.goToTab(HomePage::QUESTION_SETS_LINK_XPATH)\n \n # 2 - Click on the Question Set's name previously created from the list\n $wait.until{\n $browser.find_element(:xpath => QuestionSetsHomePage::QUESTION_SETS_HOME_BTN_NEW_XPATH).displayed? \n }\n Common.click_and_load(QuestionSetsHomePage::QUESTION_SET_LIST_XPATH + \"//*[text()[contains(.,'\" + randomName + \"')]]\") \n $wait.until{\n $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_COPY_QUESTION_SET_XPATH).displayed? \n }\n url = $browser.current_url\n # 3 - Click on \"Copy Question Set\"\n Common.click(QuestionSetsDetail::QUESTION_SETS_DETAIL_COPY_QUESTION_SET_XPATH)\n sleep(1)\n $browser.switch_to.alert.accept\n \n # 4 - Confirm copying of Question Set\n #$wait.until{\n # $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_NEW_QUESTION_XPATH).displayed?\n #}\n $wait.until{\n $browser.current_url != url\n }\n assert_match \"Copy - \" + randomName, $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_NAME_XPATH).text\n \n end",
"def detached?\n !self.attached?\n end",
"def clone_post_copy_hook(_clone_copy_output, _opts = {})\n end",
"def detachvolume\n false\n end",
"def remote_clone\n raise CommandNotImplemented\n end",
"def detached?\n @obj.nil?\n end",
"def detached?\n @obj.nil?\n end",
"def local_clone\n raise CommandNotImplemented\n end",
"def copy_revision(original)\n # we only copy the RevisionFile/RevisionDirectory entries\n new_revision = MemoryRevision.new(original.revision_identifier)\n new_revision.user_id = original.user_id\n new_revision.comment = original.comment\n new_revision.files_content = {}\n new_revision.timestamp = original.timestamp\n new_revision.server_timestamp = original.server_timestamp\n # copy files objects\n original.files.each do |object|\n if object.instance_of?(Repository::RevisionFile)\n new_object = Repository::RevisionFile.new(object.from_revision.to_s, {\n name: object.name,\n path: object.path,\n last_modified_revision: object.last_modified_revision,\n changed: false, # for copies, set this to false\n user_id: object.user_id,\n last_modified_date: object.last_modified_date,\n submitted_date: object.last_modified_date\n })\n new_revision.files_content[new_object.to_s] = original.files_content[object.to_s]\n else\n new_object = Repository::RevisionDirectory.new(object.from_revision.to_s, {\n name: object.name,\n path: object.path,\n last_modified_revision: object.last_modified_revision,\n last_modified_date: object.last_modified_date,\n submitted_date: object.last_modified_date,\n changed: false, # for copies, set this to false\n user_id: object.user_id\n })\n end\n new_revision.files.push(new_object)\n end\n new_revision # return the copy\n end",
"def test_lock_destroy\n p1 = Person.find(1)\n p2 = Person.find(1)\n assert_equal 0, p1.lock_version\n assert_equal 0, p2.lock_version\n\n p1.first_name = \"stu\"\n p1.save!\n assert_equal 1, p1.lock_version\n assert_equal 0, p2.lock_version\n\n assert_raises(ActiveRecord::StaleObjectError) { p2.destroy }\n\n assert p1.destroy\n assert_predicate p1, :frozen?\n assert_predicate p1, :destroyed?\n assert_raises(ActiveRecord::RecordNotFound) { Person.find(1) }\n end",
"def test_dup\n assert_raises(TypeError) do\n @mmap.dup\n end\n end",
"def deep_clone; end",
"def copy_to(other); end",
"def copy_missing_attributes_dcopy(in_hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\t\thsh_copy_to = deep_copy(in_hsh_copy_to)\n\t\t\t\treturn copy_missing_attributes(hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\tend",
"def detach _args\n \"detach _args;\" \n end",
"def object_copied?(\r\n s3_client,\r\n source_bucket_name,\r\n source_object_key,\r\n target_bucket_name,\r\n target_object_key\r\n)\r\n response = s3_client.copy_object(\r\n bucket: target_bucket_name,\r\n copy_source: \"#{source_bucket_name}/#{source_object_key}\",\r\n key: target_object_key\r\n )\r\n if response.copy_object_result.etag\r\n return true\r\n else\r\n return false\r\n end\r\nrescue StandardError => e\r\n puts \"Error copying object: #{e.message}\"\r\n return false\r\nend",
"def is_detached_volume?(mapping)\n # detached by volume status unless we have successfully requested attachment\n # and volume status does not yet reflect this change. an unmanaged volume\n # can also be detached.\n return 'detached' == mapping[:volume_status] && 'attached' != mapping[:management_status]\n end",
"def test_ut_diff_source_code_o1\n assert @diff_source_code_1.save\n diff_source_code_copy = DiffSourceCode.find(@diff_source_code_1.id)\n assert_equal @diff_source_code_1.diff_file_id, diff_source_code_copy.diff_file_id \n assert @diff_source_code_1.valid?\n assert @diff_source_code_1.destroy\n end",
"def copy(from, to)\n \n end",
"def test_copy\n\n checklist_1_0 = checklists(:checklist_1_0)\n \n # Try copying without logging in.\n post(:copy, { :id => checklist_1_0.id }, {})\n assert_redirected_to(:controller => 'user', :action => 'login')\n\n # Try copying from a non-Admin account.\n post(:copy, { :id => checklist_1_0.id }, rich_designer_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n #assert_equal(Pcbtr::MESSAGES[:admin_only], flash['notice'])\n\n\n # Try appending from an Admin account\n checklist = Checklist.find(checklist_1_0.id)\n assert_equal(7, checklist.designer_only_count)\n assert_equal(4, checklist.designer_auditor_count)\n assert_equal(2, checklist.dc_designer_only_count)\n assert_equal(5, checklist.dc_designer_auditor_count)\n assert_equal(0, checklist.dr_designer_only_count)\n assert_equal(2, checklist.dr_designer_auditor_count)\n\n check_count = 0\n checklist.each_check { |ch| check_count += 1 }\n assert_equal(12, check_count)\n\n checklist_count = Checklist.count\n\n admin_session = cathy_admin_session\n post(:copy, { :id => checklist_1_0.id }, admin_session)\n assert_redirected_to(:action => 'list')\n \n checklists = Checklist.find(:all, :order => \"id ASC\")\n checklist_count += 1\n assert_equal(checklist_count, checklists.size)\n\n checklist = checklists.pop\n\n assert_equal(1, checklist.major_rev_number)\n assert_equal(1, checklist.minor_rev_number)\n\n assert_equal(7, checklist.designer_only_count)\n assert_equal(4, checklist.designer_auditor_count)\n assert_equal(2, checklist.dc_designer_only_count)\n assert_equal(5, checklist.dc_designer_auditor_count)\n assert_equal(0, checklist.dr_designer_only_count)\n assert_equal(2, checklist.dr_designer_auditor_count)\n\n check_count = 0\n checklist.each_check { |ch| check_count += 1 }\n assert_equal(12, check_count)\n\n\n post(:copy, { :id => checklist_1_0.id }, admin_session)\n \n checklists = Checklist.find(:all, :order => \"id ASC\")\n checklist_count += 1\n assert_equal(checklist_count, checklists.size)\n\n checklist = checklists.pop\n\n assert_equal(1, checklist.major_rev_number)\n assert_equal(2, checklist.minor_rev_number)\n\n assert_equal(7, checklist.designer_only_count)\n assert_equal(4, checklist.designer_auditor_count)\n assert_equal(2, checklist.dc_designer_only_count)\n assert_equal(5, checklist.dc_designer_auditor_count)\n assert_equal(0, checklist.dr_designer_only_count)\n assert_equal(2, checklist.dr_designer_auditor_count)\n\n end",
"def test_clone_to_existing_directory\n clone_to_path = \"#{TEST_DATA_DIR}/clone.git\"\n\n # Create an empty dir where we want to clone a new Gitit to\n create_dir_not_exist(clone_to_path)\n\n # Try the clone\n assert_raise RuntimeError do\n Gitit.clone(@repo_path, clone_to_path)\n end\n\n cleanup_dir(clone_to_path)\n end",
"def clone_temp\n clone.tap do |c|\n def c.save(*a)\n true\n end\n end\n end",
"def copy_attributes_dcopy(in_hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\t\thsh_copy_to = deep_copy(in_hsh_copy_to)\n\t\t\t\treturn copy_attributes(hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\tend",
"def copied(src_item, item)\n end",
"def clone() end",
"def make_copy_of_repository\n false # true #false\nend",
"def detach(filename); end",
"def test2\n \n peer1_pid = fork do\n exec(\"./peer -p nodes.map -c B.chunks -f C.chunks -m 4 -i 1 -d 0\")\n end \n \n\tparent_to_child_read, parent_to_child_write = IO.pipe\n\tpeer2_pid = fork do\n\t parent_to_child_write.close\n\n\t $stdin.reopen(parent_to_child_read) or\n\t\t\traise \"Unable to redirect STDIN\"\n\n\t exec(\"./ref_peer -p nodes.map -c A.chunks -f C.chunks -m 4 -i 2 -x 2 -d 0\") \n\tend\n\tparent_to_child_read.close\n\n\tsleep 1.0\n\t## send message to standard in of peer\n\twrite_to_peer = \"GET test2.chunks test2.tar\\n\"\n\tparent_to_child_write.write(write_to_peer)\n\tparent_to_child_write.flush\n\n\t## wait for our ref_peer binary to stop\n\tpid = Process.waitpid(peer2_pid)\n\treturn_code = $? >> 8;\n\n\tsleep 3.0\n\tif (return_code == 10) \n\n \t diff_pid = fork do\n \t\texec(\"diff B.tar test2.tar\")\n \t\t end \n\t\tProcess.waitpid(diff_pid)\n\t\treturn_code = $? >> 8;\n\t\tif (return_code == 0) \n\t\t\tputs \"########### Test 2 Passed! ###########\"\n\t\telse\n\t\t\tputs \"Files B.tar and test2.tar do not match\"\n\t\t\tputs \"########### Test 2 Failed ###########\"\n\t\tend\n\telse\n\t\tputs \"ref_peer exited with failure\"\n\t\tputs \"try setting debug level to 63 for lots more output\"\n\t\tputs \"########## Test 2 Failed #########\"\n\tend\n\n\tProcess.kill(\"SIGKILL\", peer1_pid);\nend",
"def test_hc_nodeclonenodetrue\n doc = nil\n elementList = nil\n employeeNode = nil\n clonedNode = nil\n clonedList = nil\n clonedChild = nil\n clonedChildName = nil\n origList = nil\n origChild = nil\n origChildName = nil\n result = []\n \n expected = []\n \n doc = load_document(\"hc_staff\", true)\n elementList = doc.getElementsByTagName(\"p\")\n employeeNode = elementList.item(1)\n origList = employeeNode.childNodes()\n indexid4010260 = 0\n while (indexid4010260 < origList.length)\n origChild = origList.item(indexid4010260)\n origChildName = origChild.nodeName()\n expected << origChildName\n indexid4010260 += 1\n end\n clonedNode = employeeNode.cloneNode(true)\n clonedList = clonedNode.childNodes()\n indexid4010295 = 0\n while (indexid4010295 < clonedList.length)\n clonedChild = clonedList.item(indexid4010295)\n clonedChildName = clonedChild.nodeName()\n result << clonedChildName\n indexid4010295 += 1\n end\n assert_equal(expected, result, \"clone\")\n \n end",
"def copy_to_cooperative\n space = Space.accessible_by(@context).find(unsafe_params[:id])\n object = item_from_uid(unsafe_params[:object_id])\n\n if space.contributor_permission(@context) && space.member_in_cooperative?(@context.user_id)\n if object && space.shared_space\n ActiveRecord::Base.transaction do\n copy_service.copy(object, space.shared_space.uid).each do |new_object|\n SpaceEventService.call(\n space.shared_space.id,\n @context.user_id,\n nil,\n new_object,\n \"copy_to_cooperative\",\n )\n end\n end\n\n flash[:success] = \"#{object.class} successfully copied\"\n end\n else\n flash[:warning] = \"You have no permission to copy object(s) to cooperative.\"\n end\n\n redirect_back(fallback_location: space_path(space))\n end",
"def spawn_detached(args); end",
"def deep_copy(obj); end",
"def destruction?\n self.diff['attributes']['old'] && !self.diff['attributes']['new']\n end",
"def assertNotSameTest expected, object\n assertNotSame expected, object\n end",
"def clone\n copy(false)\n end",
"def copy(target_name)\n @ui.logger.debug { \"Container Copy: #{self.id}\" }\n\n target_name.nil? and raise ContainerError, \"You must supply a destination container!\"\n\n target_container = self.node.containers.select{ |c| c.id.to_sym == target_name.to_sym }.first\n target_container.nil? and raise ContainerError, \"We could not locate the target container!\"\n\n source_state = self.state\n target_state = target_container.state\n\n target_container.demolish\n target_container.create\n\n self.down\n please_wait(:ui => @ui, :message => format_object_action(self, 'Copy', :yellow)) do\n self.node.exec(%(sudo rm -rf #{target_container.lxc.fs_root}))\n self.node.exec(%(sudo rsync -a #{self.lxc.fs_root} #{target_container.lxc.container_root}))\n self.node.exec(%(sudo rm -fv #{File.join(self.lxc.fs_root, '.*provision')}))\n end\n\n # bring the source container back online if it was running before the copy operation\n (source_state == :running) and self.up\n\n # bring the target container back online if it was running before the copy operation\n (target_state == :running) and target_container.up\n\n true\n end",
"def test_clone_repo\n clone_to_path = \"#{TEST_DATA_DIR}/clone.git\"\n \n assert_nothing_raised RuntimeError do\n Gitit.clone(@repo_path, clone_to_path)\n end\n \n assert(File.exist?(\"#{clone_to_path}/HEAD\"), \"Checking HEAD file exists at #{clone_to_path}\")\n \n cleanup_dir(clone_to_path)\n end",
"def set_study_detached_state(error)\n # missing bucket errors should have one of three messages\n #\n # nil:NilClass => returned from a NoMethodError when calling bucket.files\n # forbidden, does not have storage.buckets.get access => resulting from 403 when accessing bucket as ACLs\n # have been revoked pending delete\n if /(nil\\:NilClass|does not have storage.buckets.get access|forbidden)/.match(error.message)\n Rails.logger.error \"Marking #{self.name} as 'detached' due to error reading bucket files; #{error.class.name}: #{error.message}\"\n self.update(detached: true)\n else\n # check if workspace is still available, otherwise mark detached\n begin\n ApplicationController.firecloud_client.get_workspace(self.firecloud_project, self.firecloud_workspace)\n rescue RestClient::Exception => e\n Rails.logger.error \"Marking #{self.name} as 'detached' due to missing workspace: #{self.firecloud_project}/#{self.firecloud_workspace}\"\n self.update(detached: true)\n end\n end\n end",
"def deep_clone!(options = {})\n processed_options = Para::Cloneable::IncludeTreeBuilder.new(self, cloneable_options).build\n options = options.reverse_merge(processed_options)\n callback = build_clone_callback(options.delete(:prepare))\n \n deep_clone(options) do |original, clone|\n Para::Cloneable::AttachmentsCloner.new(original, clone).clone!\n callback&.call(original, clone)\n end\n end",
"def ensure_not_in_dest; end",
"def test1\n \n peer1_pid = fork do\n exec(\"./ref_peer -p nodes.map -c A.chunks -f C.chunks -m 4 -i 1 -x 2 -d 0\")\n end \n \n\tparent_to_child_read, parent_to_child_write = IO.pipe\n\tpeer2_pid = fork do\n\t parent_to_child_write.close\n\n\t $stdin.reopen(parent_to_child_read) or\n\t\t\traise \"Unable to redirect STDIN\"\n\n\t exec(\"./peer -p nodes.map -c B.chunks -f C.chunks -m 4 -i 2 -d 0\") \n\tend\n\tparent_to_child_read.close\n\n\tsleep 1.0\n\t## send message to standard in of peer\n\twrite_to_peer = \"GET test1.chunks test1.tar\\n\"\n\tparent_to_child_write.write(write_to_peer)\n\tparent_to_child_write.flush\n\n\t## wait for our ref_peer binary to stop\n\tpid = Process.waitpid(peer1_pid)\n\treturn_code = $? >> 8;\n\n\tsleep 3.0\n\tif (return_code == 10) \n\n \t diff_pid = fork do\n \t\texec(\"diff A.tar test1.tar\")\n \t\t end \n\t\tProcess.waitpid(diff_pid)\n\t\treturn_code = $? >> 8;\n\t\tif (return_code == 0) \n\t\t\tputs \"########### Test 1 Passed! ###########\"\n\t\telse\n\t\t\tputs \"Files A.tar and test1.tar do not match\"\n\t\t\tputs \"########### Test 1 Failed ###########\"\n\t\tend\n\telse\n\t\tputs \"ref_peer exited with failure\"\n\t\tputs \"try setting debug level to 63 for lots more output\"\n\t\tputs \"########## Test 1 Failed #########\"\n\tend\n\n\tProcess.kill(\"SIGKILL\", peer2_pid);\nend",
"def clone; end",
"def clone; end",
"def clone; end",
"def copy(command)\n src = clean_up(command[1])\n dest = clean_up(command[2])\n pp @client.files.copy(src, dest)\n end",
"def empty?\n copies.empty?\n end",
"def destroy_copies\n return unless is_standard?\n\n if self.class.log_replication?\n lines = []\n lines << \"***** DESTROYING COPIES BEFORE DESTROYING STANDARD ***************************************\"\n lines << \"Source obj: #{self}\"\n Rails.logger.debug(lines.join(\"\\n\"))\n end\n\n copies(true).each{|c| c.destroy}\n return true\n end",
"def deep_copy(object)\n Marshal.load(Marshal.dump(object))\nend",
"def copy\n move(:copy)\n end",
"def test_git_diff_to_a\n work_tree = Dir.mktmpdir\n begin\n Dir.chdir(work_tree) do\n `git init`\n `git commit --allow-empty -m 'init'`\n `git worktree add --quiet child`\n Dir.chdir('child') do\n result = Git.open('.').diff.to_a\n assert_equal([], result)\n end\n end\n ensure\n FileUtils.rm_rf(work_tree)\n end\n end",
"def clone\n end",
"def clone\n end",
"def clone\n end",
"def copy(from_object)\n to_object = nil\n to_object = @to_bucket.objects[from_object.key]\n\n if to_object.exists? && from_object.content_length == to_object.content_length\n puts \"Already exists : #{from_object.key}\"\n else\n to_object.copy_from(from_object)\n to_object.acl = :public_read\n puts \"Copy object : #{from_object.key}\"\n end\n end",
"def copyAndActive(name,degats,departAbs, direction, entitySrc)\n newCopy = deep_clone()\n\n puts entitySrc.class\n if entitySrc.is_a?(Entite)\n newCopy.name= name\n newCopy.degats = degats\n newCopy.departAbs = departAbs\n newCopy.deplacer(departAbs[0],departAbs[1])\n newCopy.entitySrc= entitySrc\n newCopy.direction= [direction*5,0]\n\n @@projectilesActifs.push(newCopy)\n# changed()\n# notify_observers(Action::ADD_PROJECTILE, newCopy)\n else\n puts \"c'est pas une entite!\"\n end\n return newCopy\n end",
"def test_new_instance_doesnt_have_pass\n refute Attendee.new(100).pass?\n end",
"def bt_same_snapshot?(other)\n bt_snapshot_attributes == other.bt_snapshot_attributes\n end",
"def test_groups_methods_equality\n aaagroup1 = TacacsServerGroup.new('test1')\n aaagroup2 = TacacsServerGroup.new('test2')\n aaagroup3 = TacacsServerGroup.new('test3')\n\n groups1 = TacacsServerGroup.groups.sort\n groups2 = TacacsServerGroup.tacacs_server_groups.sort\n\n assert_equal(groups1, groups2)\n\n detach_aaaservergroup(aaagroup1)\n detach_aaaservergroup(aaagroup2)\n detach_aaaservergroup(aaagroup3)\n end",
"def copy_attachments(from_object, to_object)\n # clear existing attachments \n to_object.attachments.each {|a| a.destroy(true)}\n # and reload the association\n to_object.attachments(true)\n # copy the attachments over\n from_object.attachments.reject{|a| a.marked_for_destruction?}.each do |a|\n attachment = to_object.attachments.build(:attachable => a.attachable, :position => a.position, :container => a.container)\n attachment.save if to_object.is_a?(Page)\n end\n end",
"def call\n return broadcast(:invalid) if @participation.invalid?\n \n Participation.transaction do\n copy_participation\n end\n \n broadcast(:ok, @copied_process)\n end",
"def rollback(target_revision)\n new_content = snapshot(target_revision)\n current_content = self.content.dup\n\n unless carbon_copy.update({ content: new_content })\n return false\n end\n\n unless self.update({ content: new_content })\n carbon_copy.update!({ content: current_content })\n\n return false\n end\n\n unless revisions.where('created_at > ?', target_revision.created_at).destroy_all\n self.update!({ content: current_content })\n self.carbon_copy.update!({ content: current_content })\n\n return false\n end\n\n true\n end",
"def test_git_clone_naming_assumptions\n in_temp_dir do |_path|\n setup_test_repositories\n\n GIT_CLONE_COMMANDS.each do |command_data|\n command = command_data[:command]\n expected_path = command_data[:expected_path]\n\n output = `#{command} 2>&1`\n\n assert_match(/Cloning into (?:bare repository )?'#{expected_path}'/, output)\n FileUtils.rm_rf(expected_path)\n end\n end\n end",
"def clone\n end",
"def copy(data)\n File.popen('pbcopy', 'w') { |p| p << data.to_s }\n $?.success?\nend",
"def deepcopy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def test_add_back_a_remotely_removed_file\n a.add(\"two\" => \"two content\").commit(\"a added two\")\n a.rm(\"two\").commit(\"a removed two\")\n b.add(\"two\" => \"two content\").commit(\"b added two\")\n \n assert_equal nil, a['two']\n assert_equal \"two content\", b['two']\n \n b.pull\n \n assert_equal nil, a['two']\n assert_equal \"two content\", b['two']\n \n assert_log_equal [\n \"a added one\",\n \"a added two\",\n \"a removed two\",\n \"b added two\", \n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end",
"def deepcopy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def copy_list \n\n\tend",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def test_clone\n \tassert_equal(UI.parseCommand('clone', CloneCmd1*\" \"),UI.main(CloneCmd1))\n \tassert_equal(UI.parseCommand('clone', CloneCmd2*\" \"),UI.main(CloneCmd2))\n \tassert_equal(UI.parseCommand('clone', CloneCmdInv*\" \"),UI.main(CloneCmdInv))\n end",
"def test_pull_a_new_file\n a.add(\"two\" => \"two content\").commit(\"a added two\")\n \n assert_equal \"two content\", a['two']\n assert_equal nil, b['two']\n \n b.pull\n \n assert_equal \"two content\", a['two']\n assert_equal \"two content\", b['two']\n \n assert_log_equal [\n \"a added one\",\n \"a added two\"\n ], b\n end",
"def changes_from_clone\n changes_from_document(clone_source, true)\n end",
"def copy(defaults=[], context={})\n self.class.find(self.class.rpc_execute('copy', self.id, defaults, context), :context => context)\n end",
"def test_update_without_attributes_does_not_only_update_lock_version\n assert_nothing_raised do\n p1 = Person.create!(first_name: \"anika\")\n lock_version = p1.lock_version\n p1.save\n p1.reload\n assert_equal lock_version, p1.lock_version\n end\n end",
"def attribs_not_to_replicate(replication)\n # start with the initial, constant set\n dont_copy = ATTRIBS_NOT_TO_COPY\n\n # add the ones that are specified explicitly in the replicable options\n dont_copy += replicable_opts(:dont_copy)\n\n # don't copy foreign key field of belongs_to associations\n replicable_opts(:child_assocs).each do |assoc|\n refl = self.class.reflect_on_association(assoc)\n dont_copy << refl.foreign_key if refl.macro == :belongs_to\n end\n\n # don't copy foreign key field of parent's has_* association, if applicable\n if replicable_opts(:parent_assoc)\n dont_copy << replicable_opts(:parent_assoc).to_s + '_id'\n end\n\n # copy user-modifiable attributes IF:\n # 1. dest obj is being created OR\n # 2. dest obj attrib value has NOT deviated from std\n # therefore, if either of the above conditions is met, we should NOT add the attrib to the dont_copy list\n # in all other cases, we should add it to the dont_copy list\n replicable_opts(:user_modifiable).each do |attrib|\n\n # if we are creating, immediately we know that nothing gets added to dont_copy\n # otherwise, we need to check if value has deviated in dest obj\n unless replication.creating?\n\n # if the src attrib is or was a hash, it gets special treatment\n if send(attrib).is_a?(Hash) || send(\"#{attrib}_was\").is_a?(Hash)\n\n # get refs, ensuring no nils\n src_hash = send(attrib) || {}\n src_hash_was = send(\"#{attrib}_was\") || {}\n dest_hash = replication.dest_obj.send(attrib) || {}\n\n # loop over each key in src\n src_hash_was.each_key do |k|\n # don't copy this particular key if deviated\n dont_copy << \"#{attrib}.#{k}\" if src_hash_was[k] != dest_hash[k]\n end\n else\n # figure out if the attribute has deviated\n deviated = send(\"#{attrib}_was\") != replication.dest_obj.send(attrib)\n\n # don't copy if value has deviated\n dont_copy << attrib if deviated\n end\n end\n end\n\n dont_copy\n end",
"def skip_test_inmutable\n #they come fully loaded\n Status.load_inmutable_instances\n status1 = Status.where.all.sort_by { |s| s.code }\n status2 = Status.where.all.sort_by { |s| s.code }\n assert status1.length == 4\n assert status2.length == 4\n #same referencs\n status1.each_index do |i|\n assert status1[i].object_id==status2[i].object_id \n end\n\n #create a new object\n stt = Status.new(code: \"xx\", description: (\"xx\" + \" some desc\"))\n stt.save\n\n status1 = Status.where.all.sort_by { |s| s.code }\n status2 = Status.where.all.sort_by { |s| s.code }\n assert status1.length == 5\n assert status2.length == 5\n #same referencs\n status1.each_index do |i|\n assert status1[i].object_id==status2[i].object_id \n end \n\n status1.each do |st|\n assert st.code\n assert st.description\n end\n\n marr = Status.find(\"divorced\").first\n assert marr.code == \"divorced\"\n assert marr.description\n assert marr.object_id == status1.first.object_id\n\n people = Person.where.include(:name, status: [ :code, :description ]).all\n people.each do |p|\n assert p.status.object_id == status1.select { |st| st.id == p.status.id }.first.object_id\n assert p.status.code\n assert p.status.description\n end\n end",
"def test_remove_a_file\n a.rm(\"one\").commit(\"a removed one\")\n \n assert_equal nil, a['one']\n assert_equal \"one content\", b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\"\n ], b\n end",
"def test_merge\n # Rule is non-admins can only merge herbaria in which they own all records\n # into their own personal herbarium. Nothing else. Mary owns all the\n # records at fundis, randomly enough, so if we create a personal\n # herbarium for her, she should be able to merge fundis into it.\n assert_true(fundis.owns_all_records?(mary))\n src = fundis\n dest = mary.create_personal_herbarium\n # dest_old_name = dest.name\n login(\"mary\")\n\n assert_no_changes(\n \"dest.name\", \"Destination Herbarium should retain its name\"\n ) do\n post(:create, params: { src: src.id, dest: dest.id })\n end\n assert_flash_success\n assert_redirected_to(herbarium_path(dest))\n assert_equal(\n dest.personal_user_id, mary.id,\n \"Destination Herbarium should remain Mary's personal Herbarium\"\n )\n end",
"def clone\n @clone = true\n end",
"def clone_should_be_private?(actor)\n return false unless actor\n return false if owner_id.blank?\n return private if owner_id == actor.id\n\n actor.private_scenarios?\n end",
"def test_email\n a = copy(@email)\n sleep(@sleep)\n b = paste\n clear\n unless a == b\n alarm; puts \"E-mail address changed in clipboard!\\n\\n\"\n else\n puts \"E-mail pattern - test passed\"\n end\n end",
"def test_clone\n x = Torch.tensor([1, 2, 3])\n y = x.clone\n x.add!(1)\n assert_tensor [2, 3, 4], x\n assert_tensor [1, 2, 3], y\n end",
"def validate_copied_not_modified\n errors.add(:lesson_id, :just_been_copied) if @lesson && @lesson.copied_not_modified\n end",
"def clone_pre_copy_hook(clone_source_object, _opts = {})\n clone_source_object\n end",
"def test_remove_the_same_file_in_both_repos\n a.rm(\"one\").commit(\"a removed one\")\n b.rm(\"one\").commit(\"b removed one\")\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\",\n \"b removed one\",\n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end"
] |
[
"0.700882",
"0.6117217",
"0.5791448",
"0.55092436",
"0.54721403",
"0.53427446",
"0.5323102",
"0.53072613",
"0.5289093",
"0.5273171",
"0.5242975",
"0.5192002",
"0.5188811",
"0.51586384",
"0.5153594",
"0.51498854",
"0.51441985",
"0.5126331",
"0.5114862",
"0.5114246",
"0.5114246",
"0.5099783",
"0.50948864",
"0.50924313",
"0.50790524",
"0.50686365",
"0.5066909",
"0.5062701",
"0.50526166",
"0.5049795",
"0.50421673",
"0.50201637",
"0.5012724",
"0.50046206",
"0.4999852",
"0.49784657",
"0.49594197",
"0.49330154",
"0.4910239",
"0.49080193",
"0.49067405",
"0.4899423",
"0.4887007",
"0.48865965",
"0.48844686",
"0.48832732",
"0.488035",
"0.48627555",
"0.48615828",
"0.48575127",
"0.48516172",
"0.48503235",
"0.48430112",
"0.4842806",
"0.48412365",
"0.4835207",
"0.4835207",
"0.4835207",
"0.48181427",
"0.4817783",
"0.48153162",
"0.4809155",
"0.48073602",
"0.48042694",
"0.48031354",
"0.48031354",
"0.48031354",
"0.47970432",
"0.4794179",
"0.4781479",
"0.4772004",
"0.47675115",
"0.4762908",
"0.47610262",
"0.47569868",
"0.47508043",
"0.47364467",
"0.47317228",
"0.47255966",
"0.47041738",
"0.47036693",
"0.46841183",
"0.46838704",
"0.46838704",
"0.46808904",
"0.46758235",
"0.46692687",
"0.46543586",
"0.46511102",
"0.4644036",
"0.46435282",
"0.46407586",
"0.4637902",
"0.4632994",
"0.4619761",
"0.46104765",
"0.46084803",
"0.46013218",
"0.4599967",
"0.45979625"
] |
0.7740094
|
0
|
Test the detached_subtree_copy method.
|
def test_detached_subtree_copy
setup_test_tree
assert(@root.has_children?, "The root should have children.")
tree_copy = @root.detached_subtree_copy
assert_equal(@root.name, tree_copy.name, "The names should be equal.")
assert_not_equal(@root.object_id, tree_copy.object_id, "Object_ids should differ.")
assert(tree_copy.is_root?, "Copied root should be a root node.")
assert(tree_copy.has_children?, "Copied tree should have children.")
assert_equal(tree_copy.children.count, @root.children.count, "Copied tree and the original tree should have same number of children.")
assert_equal(tree_copy[0].name, @child1.name, "The names of Child1 (original and copy) should be same.")
assert_not_equal(tree_copy[0].object_id, @child1.object_id, "Child1 Object_ids (original and copy) should differ.")
assert(!tree_copy[0].is_root?, "Child1 copied should not be root.")
assert(!tree_copy[0].has_children?, "Child1 copied should not have children.")
assert_equal(tree_copy[1].name, @child2.name, "The names of Child2 (original and copy) should be same.")
assert_not_equal(tree_copy[1].object_id, @child2.object_id, "Child2 Object_ids (original and copy) should differ.")
assert(!tree_copy[1].is_root?, "Child2 copied should not be root.")
assert(!tree_copy[1].has_children?, "Child2 copied should not have children.")
assert_equal(tree_copy[2].name, @child3.name, "The names of Child3 (original and copy) should be same.")
assert_not_equal(tree_copy[2].object_id, @child3.object_id, "Child3 Object_ids (original and copy) should differ.")
assert(!tree_copy[2].is_root?, "Child3 copied should not be root.")
assert(tree_copy[2].has_children?, "Child3 copied should have children.")
assert_equal(tree_copy[2][0].name, @child4.name, "The names of Child4 (original and copy) should be same.")
assert_not_equal(tree_copy[2][0].object_id, @child4.object_id, "Child4 Object_ids (original and copy) should differ.")
assert(!tree_copy[2][0].is_root?, "Child4 copied should not be root.")
assert(!tree_copy[2][0].has_children?, "Child4 copied should not have children.")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_detached_copy\n setup_test_tree\n\n assert(@root.has_children?, \"The root should have children\")\n copy_of_root = @root.detached_copy\n assert(!copy_of_root.has_children?, \"The copy should not have children\")\n assert_equal(@root.name, copy_of_root.name, \"The names should be equal\")\n\n # Try the same test with a child node\n assert(!@child3.is_root?, \"Child 3 is not a root\")\n assert(@child3.has_children?, \"Child 3 has children\")\n copy_of_child3 = @child3.detached_copy\n assert(copy_of_child3.is_root?, \"Child 3's copy is a root\")\n assert(!copy_of_child3.has_children?, \"Child 3's copy does not have children\")\n end",
"def test_clone_creates_a_different_object\n obj = Object.new\n copy = obj.clone\n\n assert_equal true, obj != copy\n assert_equal true, obj.object_id != copy.object_id\n end",
"def check_subtree(small, large)\n start_node = bsearch(large.root, small.root.value)\n return false if start_node.nil?\n traverse_in_order(small.root) == traverse_in_order(start_node)\nend",
"def test_hc_nodeclonenodetrue\n doc = nil\n elementList = nil\n employeeNode = nil\n clonedNode = nil\n clonedList = nil\n clonedChild = nil\n clonedChildName = nil\n origList = nil\n origChild = nil\n origChildName = nil\n result = []\n \n expected = []\n \n doc = load_document(\"hc_staff\", true)\n elementList = doc.getElementsByTagName(\"p\")\n employeeNode = elementList.item(1)\n origList = employeeNode.childNodes()\n indexid4010260 = 0\n while (indexid4010260 < origList.length)\n origChild = origList.item(indexid4010260)\n origChildName = origChild.nodeName()\n expected << origChildName\n indexid4010260 += 1\n end\n clonedNode = employeeNode.cloneNode(true)\n clonedList = clonedNode.childNodes()\n indexid4010295 = 0\n while (indexid4010295 < clonedList.length)\n clonedChild = clonedList.item(indexid4010295)\n clonedChildName = clonedChild.nodeName()\n result << clonedChildName\n indexid4010295 += 1\n end\n assert_equal(expected, result, \"clone\")\n \n end",
"def test_marshal_dump\n # Setup Test Data\n test_root = Tree::TreeNode.new(\"ROOT\", \"Root Node\")\n test_content = {\"KEY1\" => \"Value1\", \"KEY2\" => \"Value2\" }\n test_child = Tree::TreeNode.new(\"Child\", test_content)\n test_content2 = [\"AValue1\", \"AValue2\", \"AValue3\"]\n test_grand_child = Tree::TreeNode.new(\"Grand Child 1\", test_content2)\n test_root << test_child << test_grand_child\n\n # Perform the test operation\n data = Marshal.dump(test_root) # Marshal\n new_root = Marshal.load(data) # And unmarshal\n\n # Test the root node\n assert_equal(test_root.name, new_root.name, \"Must identify as ROOT\")\n assert_equal(test_root.content, new_root.content, \"Must have root's content\")\n assert(new_root.is_root?, \"Must be the ROOT node\")\n assert(new_root.has_children?, \"Must have a child node\")\n\n # Test the child node\n new_child = new_root[test_child.name]\n assert_equal(test_child.name, new_child.name, \"Must have child 1\")\n assert(new_child.has_content?, \"Child must have content\")\n assert(new_child.is_only_child?, \"Child must be the only child\")\n\n new_child_content = new_child.content\n assert_equal(Hash, new_child_content.class, \"Class of child's content should be a hash\")\n assert_equal(test_child.content.size, new_child_content.size, \"The content should have same size\")\n\n # Test the grand-child node\n new_grand_child = new_child[test_grand_child.name]\n assert_equal(test_grand_child.name, new_grand_child.name, \"Must have grand child\")\n assert(new_grand_child.has_content?, \"Grand-child must have content\")\n assert(new_grand_child.is_only_child?, \"Grand-child must be the only child\")\n\n new_grand_child_content = new_grand_child.content\n assert_equal(Array, new_grand_child_content.class, \"Class of grand-child's content should be an Array\")\n assert_equal(test_grand_child.content.size, new_grand_child_content.size, \"The content should have same size\")\n end",
"def test_return_method_falsey\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal true, @tree.includes?(\"c\")\n end",
"def check_subtree(t1, t2)\n # Pre-compute sizes of each subtree in t1 and t2\n t1_sizes = compute_subtree_sizes(t1)\n t2_sizes = compute_subtree_sizes(t2)\n\n # Check if t2 is subtree of t1\n check_subtree_helper(t1, t2, t1_sizes, t2_sizes)\nend",
"def test_delete_node_tree_l_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [10, 8]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def check_subtree(tree1, tree2)\n # due to the depth of T1 being much larger than T2 a BFS seems more logical\n bfs(tree1.head, tree2,head)\nend",
"def test_delete_node_tree_r_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [8, 10]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def is_subtree(root)\n\nend",
"def test_git_diff_to_a\n work_tree = Dir.mktmpdir\n begin\n Dir.chdir(work_tree) do\n `git init`\n `git commit --allow-empty -m 'init'`\n `git worktree add --quiet child`\n Dir.chdir('child') do\n result = Git.open('.').diff.to_a\n assert_equal([], result)\n end\n end\n ensure\n FileUtils.rm_rf(work_tree)\n end\n end",
"def diff_subtree(tree1, tree2, path)\n ret = []\n\n # compatible classes\n if tree1.class == tree2.class\n # both subtrees are Hash\n if tree1.is_a? Hash\n keys = (tree1.keys + tree2.keys).uniq\n\n keys.each do |key|\n if tree1.key?(key) && tree2.key?(key)\n ret << diff_subtree(tree1[key],\n tree2[key],\n path + [key])\n\n elsif tree1.key?(key)\n # delete hash key\n ret << {\n 'path' => path,\n 'key' => key,\n 'old' => tree1[key],\n 'state' => 'rm',\n 'extra' => {}\n }\n else\n # insert new hash key\n ret << {\n 'path' => path,\n 'key' => key,\n 'value' => tree2[key],\n 'state' => 'ins',\n 'extra' => {}\n }\n end\n end\n\n # both subtrees are Array\n elsif tree1.is_a? Array\n if @strict\n idx = 0\n idx1 = 0\n idx2 = 0\n\n while (idx1 < tree1.length) || (idx2 < tree2.length)\n val1 = tree1[idx1]\n val2 = tree2[idx2]\n\n # We need to be sure we are comparing values\n # still inside the arrays and not valid nil\n # value with item outside the array range.\n if (idx1 < tree1.length) && (idx2 < tree2.length)\n if OneCfg::Config::Utils.deep_compare(val1,\n val2,\n @strict)\n idx += 1\n idx1 += 1\n idx2 += 1\n else\n # Inserting values:\n # 1 = A, B, C, D, E, F\n # 2 = A, B, X, C, Y, D, E, F\n # INSERT X, idx 2\n # INSERT X, idx 4\n # when on pos 2, forward lookup for 'C'\n # in tree2, find on pos 3, so add new\n # 'X' on pos 2, idx2++\n #\n # Deleting values:\n # 1 = A, B, C, D, E, F\n # 2 = A, B, E, F\n # DELETE C, idx 2\n # DELETE D, idx 2\n # when on pos 2, forward lookup for 'C'\n # in tree, don't find any, so delete\n # 'C' from pos 2, idx1++\n\n # forward lookup for val1\n fwd_found = false\n fwd_idx2 = idx2 + 1\n\n # rubocop:disable Layout/LineLength\n while (fwd_idx2 < tree2.length) && !fwd_found\n if OneCfg::Config::Utils.deep_compare(tree2[fwd_idx2], val1, @strict)\n fwd_found = true\n else\n fwd_idx2 += 1\n end\n end\n # rubocop:enable Layout/LineLength\n\n if fwd_found\n # insert array item\n ret << {\n 'path' => path,\n 'key' => nil,\n 'value' => val2,\n 'old' => val1,\n 'state' => 'ins',\n 'extra' => { 'index' => idx }\n }\n\n idx += 1\n idx2 += 1\n\n else\n # delete array item\n ret << {\n 'path' => path,\n 'key' => nil,\n 'old' => val1,\n 'state' => 'rm',\n 'extra' => { 'index' => idx }\n }\n\n idx1 += 1\n end\n end\n\n # Process remaining array items on tree1\n # by dropping them (not found on tree2)\n elsif idx1 < tree1.length\n # delete array item\n ret << {\n 'path' => path,\n 'key' => nil,\n 'old' => val1,\n 'state' => 'rm',\n 'extra' => { 'index' => idx }\n }\n\n idx1 += 1\n\n # Process remaining new array items on tree2\n # by creating them.\n else\n # insert array item\n ret << {\n 'path' => path,\n 'key' => nil,\n 'value' => val2,\n 'old' => val1,\n 'state' => 'ins',\n 'extra' => { 'index' => idx }\n }\n\n idx += 1\n idx2 += 1\n end\n end\n else\n values = (tree1 + tree2).uniq\n\n values.each do |val|\n di1 = OneCfg::Config::Utils.deep_include?(\n tree1, val, @strict\n )\n\n di2 = OneCfg::Config::Utils.deep_include?(\n tree2, val, @strict\n )\n\n if di1 && di2\n # skip\n nil\n\n elsif di1\n # delete array item\n ret << {\n 'path' => path,\n 'key' => nil,\n 'old' => val,\n 'state' => 'rm',\n 'extra' => {}\n }\n else\n # insert array item\n ret << {\n 'path' => path,\n 'key' => nil,\n 'value' => val,\n 'state' => 'ins',\n 'extra' => {}\n }\n end\n end\n end\n\n # both subtrees are Nil\n elsif tree1.is_a? NilClass\n # skip\n nil\n\n # both subtrees are of some other type\n else\n unless OneCfg::Config::Utils.deep_compare(tree1,\n tree2,\n @strict)\n # set new value\n ret << {\n 'path' => path[0..-2],\n 'key' => path[-1],\n 'value' => tree2,\n 'old' => tree1,\n 'state' => 'set',\n 'extra' => {}\n }\n end\n end\n\n # Tree1 and tree2 are not same classes. We can't compare\n # them so we take tree2 as new value to set as-is.\n else\n # set new value\n ret << {\n 'path' => path[0..-2],\n 'key' => path[-1],\n 'value' => tree2,\n 'old' => tree1,\n 'state' => 'set',\n 'extra' => {}\n }\n end\n\n ret\n end",
"def deep_copy(obj); end",
"def test_freeze_tree_bang\n setup_test_tree\n\n @root.content = \"ABC\"\n assert_equal(\"ABC\", @root.content, \"Content should be 'ABC'\")\n @root.freeze_tree!\n # Note: The error raised here depends on the Ruby version.\n # For Ruby > 1.9, RuntimeError is raised\n # For Ruby ~ 1.8, TypeError is raised\n assert_raise(RuntimeError, TypeError) {@root.content = \"123\"}\n assert_raise(RuntimeError, TypeError) {@root[0].content = \"123\"}\n end",
"def deep_copy(object)\n Marshal.load(Marshal.dump(object))\nend",
"def deep_clone; end",
"def test_delete_node_tree_mono_node\n # Prep\n tree = BST::Tree.new\n val = 10\n tree.insert(val)\n tree.delete(val)\n # Test\n exp_root, exp_count = nil, 0\n act_root, act_count = tree.root.val, tree.node_count\n #\n assert_equal exp_root, act_root\n assert_equal exp_count, act_count,\n \"deleting a node from a mono-node tree results in an empty tree, but got: #{act_count} node(s)\"\n end",
"def test_clone\n assert_raises(TypeError) do\n @mmap.clone\n end\n end",
"def copy_tree\n new_car = if car.kind_of? Cons\n car.copy_tree\n else\n car\n end\n new_cdr = if cdr.kind_of? Cons\n cdr.copy_tree\n else\n cdr\n end\n Cons[new_car,new_cdr]\n end",
"def test_delete_node_in_empty_tree\n @tree_empty.delete(0)\n assert_equal 0,\n @tree_empty.node_count,\n \"deleting a node from an empty tree is a NO-OP, but got something\"\n end",
"def test_insert_returns_1_when_2_nodes_added\n @tree.insert(\"b\")\n return_value = @tree.insert(\"a\")\n assert_equal 1, return_value\n end",
"def balanced_copy\n return BinaryTree.new(root: create_balanced_copy_subtree(elements: inorder_traversal.to_a))\n end",
"def create_balanced_copy_subtree(elements:)\n return nil if elements.empty?\n\n\n centre_ix = (elements.size / 2).floor\n return Node.new(\n elements[centre_ix][0],\n elements[centre_ix][1],\n create_balanced_copy_subtree(elements: elements[0...(centre_ix)]),\n create_balanced_copy_subtree(elements: elements[(centre_ix+1)..-1]),\n )\n end",
"def descendants_affected\n descendants\n end",
"def copy_revision(original)\n # we only copy the RevisionFile/RevisionDirectory entries\n new_revision = MemoryRevision.new(original.revision_identifier)\n new_revision.user_id = original.user_id\n new_revision.comment = original.comment\n new_revision.files_content = {}\n new_revision.timestamp = original.timestamp\n new_revision.server_timestamp = original.server_timestamp\n # copy files objects\n original.files.each do |object|\n if object.instance_of?(Repository::RevisionFile)\n new_object = Repository::RevisionFile.new(object.from_revision.to_s, {\n name: object.name,\n path: object.path,\n last_modified_revision: object.last_modified_revision,\n changed: false, # for copies, set this to false\n user_id: object.user_id,\n last_modified_date: object.last_modified_date,\n submitted_date: object.last_modified_date\n })\n new_revision.files_content[new_object.to_s] = original.files_content[object.to_s]\n else\n new_object = Repository::RevisionDirectory.new(object.from_revision.to_s, {\n name: object.name,\n path: object.path,\n last_modified_revision: object.last_modified_revision,\n last_modified_date: object.last_modified_date,\n submitted_date: object.last_modified_date,\n changed: false, # for copies, set this to false\n user_id: object.user_id\n })\n end\n new_revision.files.push(new_object)\n end\n new_revision # return the copy\n end",
"def test_save_tree\n end",
"def test_load_ignores_duplicates\n tree = BinarySearchTree.new\n tree.load\n target = tree.load\n assert_nil target\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def copy_tags_to_snapshot\n data[:copy_tags_to_snapshot]\n end",
"def copy_tags_to_snapshot\n data[:copy_tags_to_snapshot]\n end",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def copy_missing_attributes_dcopy(in_hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\t\thsh_copy_to = deep_copy(in_hsh_copy_to)\n\t\t\t\treturn copy_missing_attributes(hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\tend",
"def test_remove_bang\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove!(@child1)\n assert_equal(2, @root.size, \"Should have two nodes\")\n @root.remove!(@child2)\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n # Some negative testing\n @root.remove!(nil)\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def deep_copy(obj)\n Marshal.load(Marshal.dump(obj))\nend",
"def test_pull_a_new_file_into_a_modified_tree\n b.add(\"dir/three\" => \"three content\").commit(\"b added three\")\n a.add(\"dir/two\" => \"two content\").commit(\"a added two\")\n \n assert_equal \"two content\", a['dir/two']\n assert_equal nil, b['dir/two']\n assert_equal \"three content\", b['dir/three']\n \n b.pull\n \n assert_equal \"two content\", a['dir/two']\n assert_equal \"two content\", b['dir/two']\n assert_equal \"three content\", b['dir/three']\n \n assert_log_equal [\n \"a added one\",\n \"a added two\",\n \"b added three\", \n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def deepcopy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def deepcopy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def test_unflatten_perfind2\r\n pi = @mymodel.node_list.add_node(4, 'perfind4', PERFIND)\r\n \r\n data = pi.flatten_data\r\n \r\n @mymodel.node_list.delete_node(pi)\r\n \r\n livenode = @mymodel.node_list.node_from_data(data)\r\n \r\n assert_equal(pi.ident, livenode.ident) \r\n assert_equal(pi.value_function, livenode.value_function) \r\n end",
"def test_clone_to_existing_directory\n clone_to_path = \"#{TEST_DATA_DIR}/clone.git\"\n\n # Create an empty dir where we want to clone a new Gitit to\n create_dir_not_exist(clone_to_path)\n\n # Try the clone\n assert_raise RuntimeError do\n Gitit.clone(@repo_path, clone_to_path)\n end\n\n cleanup_dir(clone_to_path)\n end",
"def test_insert_node_to_right\n @tree.insert(\"c\")\n @tree.insert(\"a\")\n @tree.insert(\"d\")\n refute_equal nil, @tree.root.right\n end",
"def check_snapshot(vmname, node)\n if node.name =~ /^prekernel/\n compare_time = Time.now - CLEAN_AFTER_DAYS * 24 * 60 * 60\n if compare_time > node.createTime\n puts 'Deleting snapshot for ' + vmname + ' | ' + node.name + ' | ' + node.createTime.iso8601\n\n snapshot_task = node.snapshot.RemoveSnapshot_Task(removeChildren: false)\n snapshot_task = snapshot_task.wait_for_completion\n end\n end\n\n unless node.childSnapshotList.empty?\n node.childSnapshotList.each { |item| check_snapshot(vmname, item) }\n end\nend",
"def deep_copy object\n Marshal.load(Marshal.dump(object))\n end",
"def deep_copy object\n Marshal.load(Marshal.dump(object))\n end",
"def test_return_method_truthy\n @tree.insert(\"a\")\n @tree.insert(\"c\")\n assert_equal true, @tree.includes?(\"c\")\n end",
"def deep_copy\n Marshal.load(Marshal.dump(self))\n end",
"def dup_tree\n return @tree.dup\n end",
"def child_tree\n child_check\n child_tree = self.clone\n child_tree.removeFromParent!\n child_tree\n end",
"def test_hc_nodeappendchildchildexists\n doc = nil\n elementList = nil\n childList = nil\n childNode = nil\n newChild = nil\n memberNode = nil\n memberName = nil\n refreshedActual = []\n \n actual = []\n \n nodeType = nil\n expected = []\n expected << \"strong\"\n expected << \"code\"\n expected << \"sup\"\n expected << \"var\"\n expected << \"acronym\"\n expected << \"em\"\n \n appendedChild = nil\n doc = load_document(\"hc_staff\", true)\n elementList = doc.getElementsByTagName(\"p\")\n childNode = elementList.item(1)\n childList = childNode.getElementsByTagName(\"*\")\n newChild = childList.item(0)\n appendedChild = childNode.appendChild(newChild)\n indexid3799224 = 0\n while (indexid3799224 < childList.length)\n memberNode = childList.item(indexid3799224)\n memberName = memberNode.nodeName()\n actual << memberName\n indexid3799224 += 1\n end\n assertEqualsAutoCase(\"element\", \"liveByTagName\", expected, actual)\n childList = childNode.childNodes()\n indexid3799263 = 0\n while (indexid3799263 < childList.length)\n memberNode = childList.item(indexid3799263)\n nodeType = memberNode.nodeType()\n \n if (equals(1, nodeType))\n memberName = memberNode.nodeName()\n refreshedActual << memberName\n \n end\n indexid3799263 += 1\n end\n assertEqualsAutoCase(\"element\", \"refreshedChildNodes\", expected, refreshedActual)\n \n end",
"def deep_copy_node(oldhash)\n newhash = {}\n newhash['fqdn'] = oldhash['fqdn'] || oldhash['id'].gsub('_', '.') # Fix the fqdn, since periods couldn't be used in the databag ID.\n newhash['chef_environment'] = oldhash['chef_environment']\n begin\n newhash['chef_environment'] ||= oldhash.chef_environment # In case it's an actual Chef node and not a hash emulating one.\n rescue\n end\n newhash['rdiff-backup'] = oldhash['rdiff-backup'].to_hash\n return newhash\nend",
"def undumpable?(object)\n !can_be_fully_dumped?(object) && !can_be_dumped_as_copy?(object)\n end",
"def copy_attributes_dcopy(in_hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\t\thsh_copy_to = deep_copy(in_hsh_copy_to)\n\t\t\t\treturn copy_attributes(hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\tend",
"def test_CopyQuestionSet\n randomName = SecureRandom.hex(4)\n \n #PRECONDITION: Must be logged in\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n \n #Create an empty Question Sets\n self.CreateQuestionSetEmpty(randomName)\n \n # 1 - Go to \"Question Sets\" Tab\n Common.goToTab(HomePage::QUESTION_SETS_LINK_XPATH)\n \n # 2 - Click on the Question Set's name previously created from the list\n $wait.until{\n $browser.find_element(:xpath => QuestionSetsHomePage::QUESTION_SETS_HOME_BTN_NEW_XPATH).displayed? \n }\n Common.click_and_load(QuestionSetsHomePage::QUESTION_SET_LIST_XPATH + \"//*[text()[contains(.,'\" + randomName + \"')]]\") \n $wait.until{\n $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_COPY_QUESTION_SET_XPATH).displayed? \n }\n url = $browser.current_url\n # 3 - Click on \"Copy Question Set\"\n Common.click(QuestionSetsDetail::QUESTION_SETS_DETAIL_COPY_QUESTION_SET_XPATH)\n sleep(1)\n $browser.switch_to.alert.accept\n \n # 4 - Confirm copying of Question Set\n #$wait.until{\n # $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_NEW_QUESTION_XPATH).displayed?\n #}\n $wait.until{\n $browser.current_url != url\n }\n assert_match \"Copy - \" + randomName, $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_NAME_XPATH).text\n \n end",
"def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)\r\n Entry_.new(src, nil, dereference_root).traverse do |ent|\r\n destent = Entry_.new(dest, ent.rel, false)\r\n File.unlink destent.path if remove_destination && File.file?(destent.path)\r\n ent.copy destent.path\r\n ent.copy_metadata destent.path if preserve\r\n end\r\n end",
"def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)\r\n Entry_.new(src, nil, dereference_root).traverse do |ent|\r\n destent = Entry_.new(dest, ent.rel, false)\r\n File.unlink destent.path if remove_destination && File.file?(destent.path)\r\n ent.copy destent.path\r\n ent.copy_metadata destent.path if preserve\r\n end\r\n end",
"def can_be_dumped_as_copy?(object)\n begin\n copy = object.class.allocate\n Marshal.dump(copy)\n true\n rescue StandardError\n false\n end\n end",
"def test_expression_clone_named_group\n root = RP.parse('^(?<somename>a)+bc$')\n copy = root.clone\n\n root_1 = root.expressions[1]\n copy_1 = copy.expressions[1]\n\n # The names are equal but their objects are not.\n assert_equal copy_1.name, root_1.name\n refute_equal copy_1.name.object_id, root_1.name.object_id\n\n # Verify super: text objects should be different.\n assert_equal copy_1.text, root_1.text\n\n # Verify super: expressions arrays are not equal.\n refute_equal copy_1.expressions.object_id,\n root_1.expressions.object_id\n\n # Verify super: expressions in the arrays are not equal.\n copy_1.expressions.each_with_index do |exp, index|\n refute_equal exp.object_id,\n root_1.expressions[index].object_id\n end\n end",
"def deep_copy\n deep_transform_values(&method(:_deep_copy))\n end",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def copy(element)\n puts element.text\nend",
"def test_ut_diff_warning_01\n assert @diff_warning.save\n assert @diff_warning.valid?\n diff_warning_copy = DiffWarning.find(@diff_warning.id)\n assert_equal @diff_warning.diff_file_id, diff_warning_copy.diff_file_id\n assert @diff_warning.destroy\n end",
"def test_modified\n parent = RoBaseIf.new( 'parent', '' )\n base = RoBaseIf.new( 'lab1', '' )\n base.parent = parent\n assert_equal false, parent.modified\n assert_equal false, base.modified\n base.value = 'A'\n assert_equal true, parent.modified\n assert_equal true, base.modified\n end",
"def deep_copy(o)\n\tMarshal.load(Marshal.dump(o))\nend",
"def initialize_copy(other)\n # Think the assertion which fails if the after_initialize callback goes at the end of the method is wrong. The\n # deleted clone method called new which therefore called the after_initialize callback. It then went on to copy\n # over the attributes. But if it's copying the attributes afterwards then it hasn't finished initializing right?\n # For example in the test suite the topic model's after_initialize method sets the author_email_address to\n # test@test.com. I would have thought this would mean that all cloned models would have an author email address\n # of test@test.com. However the test_clone test method seems to test that this is not the case. As a result the\n # after_initialize callback has to be run *before* the copying of the atrributes rather than afterwards in order\n # for all tests to pass. This makes no sense to me.\n callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)\n cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)\n # CPK\n #cloned_attributes.delete(self.class.primary_key)\n self.class.primary_key.each {|key| cloned_attributes.delete(key.to_s)}\n\n @attributes = cloned_attributes\n clear_aggregation_cache\n @attributes_cache = {}\n @new_record = true\n ensure_proper_type\n\n if scope = self.class.send(:current_scoped_methods)\n create_with = scope.scope_for_create\n create_with.each { |att,value| self.send(\"#{att}=\", value) } if create_with\n end\n end",
"def copy( newdn, attributes={} )\n\n\t\t# Fully-qualify RDNs\n\t\tnewdn = newdn + ',' + self.parent_dn unless newdn.index(',')\n\n\t\tself.log.debug \"Creating a copy of %p at %p\" % [ self.dn, newdn ]\n\t\tnewbranch = self.class.new( self.directory, newdn )\n\n\t\tattributes = self.entry.merge( stringify_keys(attributes) )\n\n\t\tself.log.debug \" merged attributes: %p\" % [ attributes ]\n\t\tself.directory.create( newbranch, attributes )\n\n\t\treturn newbranch\n\tend",
"def check_integrity(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"stray node found in level: #{l} which is #{list.to_a(nil,nil,nil,l)}\" if !difference.empty? \n expect(difference).to match_array([])\n end\nend",
"def copy_to(other); end",
"def test_delve\n top = mk_transtree do |object, depth, width|\n object.file = :funtest if width % 2 == 1\n end\n\n objects = []\n buckets = []\n found = []\n\n count = 0\n assert_nothing_raised {\n top.delve do |object|\n count += 1\n if object.is_a? Puppet::TransBucket\n buckets << object\n else\n objects << object\n if object.file == :funtest\n found << object\n end\n end\n end\n }\n\n top.flatten.each do |obj|\n assert(objects.include?(obj), \"Missing obj #{obj.type}[#{obj.name}]\")\n end\n\n\n assert_equal(\n found.length,\n top.flatten.find_all { |o| o.file == :funtest }.length,\n \n \"Found incorrect number of objects\")\n end",
"def deep_copy\n Query.new(\n modifier.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},\n type.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},\n expressions.map {|e| e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}})\n end",
"def deep_copy(object)\n Marshal.load(Marshal.dump(object))\n end",
"def test_delete\n private_user = create(:user, :data_public => false)\n private_user_changeset = create(:changeset, :user => private_user)\n private_user_closed_changeset = create(:changeset, :closed, :user => private_user)\n private_node = create(:node, :changeset => private_user_changeset)\n private_deleted_node = create(:node, :deleted, :changeset => private_user_changeset)\n\n ## first try to delete node without auth\n delete :delete, :params => { :id => private_node.id }\n assert_response :unauthorized\n\n ## now set auth for the non-data public user\n basic_authorization private_user.email, \"test\"\n\n # try to delete with an invalid (closed) changeset\n content update_changeset(private_node.to_xml, private_user_closed_changeset.id)\n delete :delete, :params => { :id => private_node.id }\n assert_require_public_data(\"non-public user shouldn't be able to delete node\")\n\n # try to delete with an invalid (non-existent) changeset\n content update_changeset(private_node.to_xml, 0)\n delete :delete, :params => { :id => private_node.id }\n assert_require_public_data(\"shouldn't be able to delete node, when user's data is private\")\n\n # valid delete now takes a payload\n content(private_node.to_xml)\n delete :delete, :params => { :id => private_node.id }\n assert_require_public_data(\"shouldn't be able to delete node when user's data isn't public'\")\n\n # this won't work since the node is already deleted\n content(private_deleted_node.to_xml)\n delete :delete, :params => { :id => private_deleted_node.id }\n assert_require_public_data\n\n # this won't work since the node never existed\n delete :delete, :params => { :id => 0 }\n assert_require_public_data\n\n ## these test whether nodes which are in-use can be deleted:\n # in a way...\n private_used_node = create(:node, :changeset => private_user_changeset)\n create(:way_node, :node => private_used_node)\n\n content(private_used_node.to_xml)\n delete :delete, :params => { :id => private_used_node.id }\n assert_require_public_data \"shouldn't be able to delete a node used in a way (#{@response.body})\"\n\n # in a relation...\n private_used_node2 = create(:node, :changeset => private_user_changeset)\n create(:relation_member, :member => private_used_node2)\n\n content(private_used_node2.to_xml)\n delete :delete, :params => { :id => private_used_node2.id }\n assert_require_public_data \"shouldn't be able to delete a node used in a relation (#{@response.body})\"\n\n ## now setup for the public data user\n user = create(:user, :data_public => true)\n changeset = create(:changeset, :user => user)\n closed_changeset = create(:changeset, :closed, :user => user)\n node = create(:node, :changeset => changeset)\n basic_authorization user.email, \"test\"\n\n # try to delete with an invalid (closed) changeset\n content update_changeset(node.to_xml, closed_changeset.id)\n delete :delete, :params => { :id => node.id }\n assert_response :conflict\n\n # try to delete with an invalid (non-existent) changeset\n content update_changeset(node.to_xml, 0)\n delete :delete, :params => { :id => node.id }\n assert_response :conflict\n\n # try to delete a node with a different ID\n other_node = create(:node)\n content(other_node.to_xml)\n delete :delete, :params => { :id => node.id }\n assert_response :bad_request,\n \"should not be able to delete a node with a different ID from the XML\"\n\n # try to delete a node rubbish in the payloads\n content(\"<delete/>\")\n delete :delete, :params => { :id => node.id }\n assert_response :bad_request,\n \"should not be able to delete a node without a valid XML payload\"\n\n # valid delete now takes a payload\n content(node.to_xml)\n delete :delete, :params => { :id => node.id }\n assert_response :success\n\n # valid delete should return the new version number, which should\n # be greater than the old version number\n assert @response.body.to_i > node.version,\n \"delete request should return a new version number for node\"\n\n # deleting the same node twice doesn't work\n content(node.to_xml)\n delete :delete, :params => { :id => node.id }\n assert_response :gone\n\n # this won't work since the node never existed\n delete :delete, :params => { :id => 0 }\n assert_response :not_found\n\n ## these test whether nodes which are in-use can be deleted:\n # in a way...\n used_node = create(:node, :changeset => create(:changeset, :user => user))\n way_node = create(:way_node, :node => used_node)\n way_node2 = create(:way_node, :node => used_node)\n\n content(used_node.to_xml)\n delete :delete, :params => { :id => used_node.id }\n assert_response :precondition_failed,\n \"shouldn't be able to delete a node used in a way (#{@response.body})\"\n assert_equal \"Precondition failed: Node #{used_node.id} is still used by ways #{way_node.way.id},#{way_node2.way.id}.\", @response.body\n\n # in a relation...\n used_node2 = create(:node, :changeset => create(:changeset, :user => user))\n relation_member = create(:relation_member, :member => used_node2)\n relation_member2 = create(:relation_member, :member => used_node2)\n\n content(used_node2.to_xml)\n delete :delete, :params => { :id => used_node2.id }\n assert_response :precondition_failed,\n \"shouldn't be able to delete a node used in a relation (#{@response.body})\"\n assert_equal \"Precondition failed: Node #{used_node2.id} is still used by relations #{relation_member.relation.id},#{relation_member2.relation.id}.\", @response.body\n end",
"def test_unflatten_process\r\n proc = @mymodel.node_list.add_node(1, 'proc1', PROCESS)\r\n proc.commentary='com'\r\n proc.description='dsc' \r\n proc.evidence=0.23\r\n \r\n data = proc.flatten_data\r\n \r\n @mymodel.node_list.delete_node(proc)\r\n \r\n livenode = @mymodel.node_list.node_from_data(data)\r\n \r\n assert_equal(proc.ident, livenode.ident) \r\n assert_equal(proc.name, livenode.name) \r\n assert_equal(proc.node_type, livenode.node_type) \r\n assert_equal(proc.commentary, livenode.commentary) \r\n assert_equal(proc.description, livenode.description) \r\n assert_equal(proc.evidence, livenode.evidence) \r\n end",
"def deep_copy\n Sass::Tree::Visitors::DeepCopy.visit(self)\n end",
"def touch?( other )\n\t\tcommon_leaves = [ ]\n\t\tother.leaves.each do |leaf|\n\t\t\t@leaves.include?(leaf) and common_leaves << leaf\n\t\tend\n\t\tif common_leaves.size > 0\n\t\t\tcommon_leaves.first\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def test_insert_returns_depth_0_if_just_root\n return_value = @tree.insert(\"a\")\n assert_equal 0, return_value\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def test_hc_noderemovechild\n doc = nil\n rootNode = nil\n childList = nil\n childToRemove = nil\n removedChild = nil\n parentNode = nil\n doc = load_document(\"hc_staff\", true)\n rootNode = doc.documentElement()\n childList = rootNode.childNodes()\n childToRemove = childList.item(1)\n removedChild = rootNode.removeChild(childToRemove)\n parentNode = removedChild.parentNode()\n assert_nil(parentNode, \"parentNodeNull\")\n \n end",
"def copy_tree_to(key, source_root, source_key)\n source_root.unprefixed_subtree_keys(source_key).each do |unprefixed_key|\n copy_content_to(File.join(key, unprefixed_key), source_root, File.join(source_key, unprefixed_key))\n end\n end",
"def update_subtree\n children.find_all {|child| child.kind_of?(NonLeafNode)}.each do |child|\n child.update_subtree\n end\n update_shash(false)\n end",
"def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end",
"def test_has_content_eh\n a_node = Tree::TreeNode.new(\"A Node\")\n assert_nil(a_node.content , \"The node should not have content\")\n assert(!a_node.has_content? , \"The node should not have content\")\n\n a_node.content = \"Something\"\n assert_not_nil(a_node.content, \"The node should now have content\")\n assert(a_node.has_content?, \"The node should now have content\")\n end",
"def copy(source_repo_id, destination_repo_id, optional = {})\n criteria = {:type_ids => [content_type], :filters => {}}\n criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:ids]}} if optional[:ids]\n criteria[:filters] = optional[:filters] if optional[:filters]\n criteria[:fields] = {:unit => optional[:fields]} if optional[:fields]\n\n payload = {:criteria => criteria}\n payload[:override_config] = optional[:override_config] if optional.key?(:override_config)\n\n if optional[:copy_children]\n payload[:override_config] ||= {}\n payload[:override_config][:recursive] = true\n end\n\n Runcible::Extensions::Repository.new(self.config).unit_copy(destination_repo_id, source_repo_id, payload)\n end",
"def deep_copy\r\n Marshal.load(Marshal.dump(self))\r\n end",
"def test_unflatten_link\r\n link = @link_list.add_link(@perfind, @proc) \r\n \r\n data = link.flatten_data\r\n \r\n @link_list.remove_link(link)\r\n \r\n livelink = @link_list.link_from_data(data)\r\n \r\n assert_equal(link.from, livelink.from) \r\n assert_equal(link.to, livelink.to) \r\n end",
"def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end",
"def deep_copy(hash)\n Marshal.load(Marshal.dump(hash))\n end",
"def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)\n if dereference_root\n src = File.realpath(src)\n end\n\n Entry_.new(src, nil, false).wrap_traverse(proc do |ent|\n destent = Entry_.new(dest, ent.rel, false)\n File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))\n ent.copy destent.path\n end, proc do |ent|\n destent = Entry_.new(dest, ent.rel, false)\n ent.copy_metadata destent.path if preserve\n end)\n end",
"def test_remove_all_bang\n setup_test_tree\n assert(@root.has_children?, \"Should have children\")\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def test(list)\n complete = list.to_a\n 1.upto(list.level) do |l|\n #if anything in the higher layer wasn't in layer 0\n difference = list.to_a(nil,nil,nil,l) - complete\n puts \"test failed level #{l} ,inconsistent node(s) #{difference}\" if (difference.count != 0)\n end\n puts \"test complete\"\nend",
"def test_drop_edges_recognizes_sub_transaction\n s0, ea, eb, ec = nil\n fa = Automaton.new do |fa|\n s0 = fa.add_state(:initial => true)\n ea = fa.connect(s0, s0, 'a')\n eb = fa.connect(s0, s0, 'b')\n ec = fa.connect(s0, s0, 'c')\n end\n fa.drop_edges(ea, eb, ec)\n assert_equal(0, fa.edge_count)\n assert_equal(0, s0.in_edges.size)\n assert_equal(0, s0.out_edges.size)\n end",
"def deep_dup; end",
"def initialize_copy(_original)\n new_children = {}\n @children.each do |child_name, child_group|\n new_children[child_name] = []\n child_group.each do |child|\n cloned_child = child.clone\n cloned_child.parent = self\n # cloned_child.root = @root\n new_children[child_name] << cloned_child\n end\n end\n @children = new_children\n end",
"def deep_clone(parent_deployment=nil, name=nil, with_nodes=true)\n\n new_snap = self.dup\n\n Snapshot.transaction begin \n new_snap.deployment_id = parent_deployment.id if parent_deployment\n new_snap.name = name || \"#{self.name}_#{self.id}\"\n new_snap.save \n # TODO ZEHICLE clone the roles\n # TODO ZEHICLE clone the nodes\n end\n\n new_snap\n end",
"def copy\n \n end",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\n end",
"def test_clone_repo\n clone_to_path = \"#{TEST_DATA_DIR}/clone.git\"\n \n assert_nothing_raised RuntimeError do\n Gitit.clone(@repo_path, clone_to_path)\n end\n \n assert(File.exist?(\"#{clone_to_path}/HEAD\"), \"Checking HEAD file exists at #{clone_to_path}\")\n \n cleanup_dir(clone_to_path)\n end",
"def copy(from, to)\n @parent.gemset_copy(from, to)\n end"
] |
[
"0.8262548",
"0.55862147",
"0.55859387",
"0.5510041",
"0.5429278",
"0.54041034",
"0.5393935",
"0.51875526",
"0.5151589",
"0.5133615",
"0.51270664",
"0.5110476",
"0.5052661",
"0.5042424",
"0.50371915",
"0.50181377",
"0.5002533",
"0.5002492",
"0.4940325",
"0.49332863",
"0.49327606",
"0.4923595",
"0.4900324",
"0.48923936",
"0.48841766",
"0.48819995",
"0.4881916",
"0.48660362",
"0.48612013",
"0.4854612",
"0.4854612",
"0.48467484",
"0.48467484",
"0.48456848",
"0.48415738",
"0.48333067",
"0.48205975",
"0.4817831",
"0.48164052",
"0.4816315",
"0.48114938",
"0.48039812",
"0.47917646",
"0.4785395",
"0.4785346",
"0.47771823",
"0.47771823",
"0.4774562",
"0.4768661",
"0.4763963",
"0.47571492",
"0.47538322",
"0.4750138",
"0.47482002",
"0.47451696",
"0.47362688",
"0.47245568",
"0.47245568",
"0.47229895",
"0.47191867",
"0.47122258",
"0.47105777",
"0.47075716",
"0.4701818",
"0.47004455",
"0.46997002",
"0.46988854",
"0.46967822",
"0.46916392",
"0.46859327",
"0.4683675",
"0.46718907",
"0.46703455",
"0.4665748",
"0.4660034",
"0.46442062",
"0.46377304",
"0.46367177",
"0.46364453",
"0.4630786",
"0.4630121",
"0.4623546",
"0.46192685",
"0.46158224",
"0.46042594",
"0.45992416",
"0.45905226",
"0.45841053",
"0.45813245",
"0.45798624",
"0.45773888",
"0.45756456",
"0.45749643",
"0.45659035",
"0.4556938",
"0.45568642",
"0.45562023",
"0.4551463",
"0.45512128",
"0.4545096"
] |
0.8244235
|
1
|
Test the has_children? method.
|
def test_has_children_eh
setup_test_tree
assert(@root.has_children?, "The Root node MUST have children")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_children?\n false\n end",
"def has_children?\n !children.empty?\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def have_children?\n children.count != 0\n end",
"def has_children?\n !self.children.empty?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n children.any?\n end",
"def has_children?\n @children.length > 0\n end",
"def children?\n !children.empty?\n end",
"def children?\n !children.empty?\n end",
"def children?\n !@children.empty?\n end",
"def has_children?\n !leaf?\n end",
"def has_children?\n ( self[:has_children] == 1 )\n end",
"def children?\n !children.empty?\n end",
"def has_child?\n !@children.empty?\n end",
"def has_children?\n @nodes && !@nodes.empty?\n end",
"def children?\n\t\t\t@children && !@children.empty?\n\t\tend",
"def children?\n self.children.any?\n end",
"def hasChildren?\n children = getChildren\n return false if children.empty? or children.nil?\n return true\n end",
"def children?\n\t\t\treturn children.size > 0\n\t\tend",
"def children?\n return false if @children.length == 0\n end",
"def children?\n\t\t\t@children.size > 0 ? true : false\n\t\tend",
"def has_children()\n return 1 if(@children.length > 0)\n 0\n end",
"def children_exist?\n\tend",
"def children?\n return false if ((self.children == nil) || (self.children == []))\n return true\n end",
"def has_children?\n bag.has_children?(path)\n end",
"def has_children?\n\t return true unless self.child_a.nil? || self.child_b.nil? \n\tend",
"def children?\n @contents.children?\n end",
"def has_children?\n `#@native.hasChildren()`\n end",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def has_children?\n return call_ancestry_method(:has_children?) if use_ancestry?\n\n relationships.any?(&:has_children?)\n end",
"def has_children?\n @nokogiri.children.any? {|child| child.kind_of? Nokogiri::XML::Element }\n end",
"def has_children?(tree_node)\n tree_node.left || tree_node.right\n end",
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def children_are_leaves?\n unless leaf?\n @children[0].leaf?\n end\n end",
"def leaf?\n children.empty?\n end",
"def leaf?\n @children.length.zero?\n end",
"def has_children?(path)\n return false if (! path_exist? path)\n # prune at level 2 (direct children) and ignore the hit for self\n @content_tree.subtree(path, nil, 2, true).count > 1\n end",
"def child_of?(parent); end",
"def leaf?\n @children.empty?\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def is_only_child?\n return false if parent.nil? # root\n 1 == parent.children.size\n end",
"def has_children?(type=\"page\", content=nil)\n node = content || @content || Content.get(params[:id]) || nil\n \n if ( node && Content.all(:parent => node.id, :content_type => type).count > 0 )\n return true\n else\n return false\n end \n \n end",
"def leaf?\n self.children.size == 0\n end",
"def is_child?\n !is_parent?\n end",
"def is_leaf?\n self.children_count.zero?\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def check_if_has_children\n self.lookups.count == 0\n end",
"def has_child(name)\n @hasChild = name\n end",
"def empty?\n @children.empty?\n end",
"def child?\n true\n end",
"def child?\n false\n end",
"def nested_child?\n @elements.last.class.method_defined?('add_element') && @elements.last.container\n end",
"def has_children(child_types)\n @child_types = child_types\n\n define_method_child_types\n define_method_children\n define_method_accepts\n end",
"def child_of?(category, options = {})\n category.children.exists?(id)\n end",
"def focusable?\n @children.any?\n end",
"def children?(this_level)\n @reader.level > this_level\n end",
"def preserve_children?\n false\n end",
"def rearrange_children?\n !!@rearrange_children\n end",
"def no_children?(node)\n return true unless node\n node.left.nil? && node.right.nil?\n end",
"def hasChildren\n if (@left == nil) && (@right == nil)\n return 0\n elsif (@left != nil) && (@right != nil)\n return 2\n else\n return 1\n end\n end",
"def leaf?\n children.where(parent_id: self.id).empty?\n end",
"def render_children_for_page?(page, depth)\n depth.succ <= @_options[:depth].to_i && children_of(page).any?\n end",
"def hasChild?\n @path.size > 1\n end",
"def leaf?\n persisted? && if children_counter_cache_column\n self[children_counter_cache_column] == 0\n else\n children.count == 0\n end\n end",
"def any_child_open?\n self.children.each do |e|\n return true unless e.completed\n end\n false\n end",
"def nested_child?\n @options.last.last.class.method_defined?('add_element') && @options.last.last.container\n end",
"def test_children\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n assert(!@child3.is_leaf?, \"Should not be a leaf\")\n\n assert_equal(1, @child3.node_height, \"The subtree at Child 3 should have a height of 1\")\n for child in [@child1, @child2, @child4]\n assert_equal(0, child.node_height, \"The subtree at #{child.name} should have a height of 0\")\n end\n\n children = []\n for child in @root.children\n children << child\n end\n\n assert_equal(3, children.length, \"Should have three direct children\")\n assert(!children.include?(@root), \"Should not have root\")\n assert(children.include?(@child1), \"Should have child 1\")\n assert(children.include?(@child2), \"Should have child 2\")\n assert(children.include?(@child3), \"Should have child 3\")\n assert(!children.include?(@child4), \"Should not have child 4\")\n\n children.clear\n children = @root.children\n assert_equal(3, children.length, \"Should have three children\")\n end",
"def has_child?(childPath)\n `#@native.hasChild(childPath)`\n end",
"def leaf?\n record.persisted? && if children.loaded? || tree.columns.counter_cache?\n # no SQL-queries here\n children.empty?\n else\n !children.exists?\n end\n end",
"def no_children(node)\n return true if node.left.nil? && node.right.nil?\n false\n end",
"def child?\n !_parent_id.nil?\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def node_can_have_children!(node)\n unless node.children\n node.children = []\n self.node_changes = node\n end\n end",
"def leaf?(r)\n r.children.empty?\n end",
"def is_only_child?\n return call_ancestry_method(:is_only_child?) if use_ancestry?\n\n relationships.all?(&:is_only_child?)\n end",
"def children\n child_check\n super\n end",
"def is_childless?\n return call_ancestry_method(:is_childless?) if use_ancestry?\n\n relationships.all?(&:is_childless?)\n end"
] |
[
"0.8574548",
"0.8568535",
"0.85664934",
"0.85664934",
"0.85439277",
"0.85439277",
"0.85439277",
"0.85439277",
"0.8538637",
"0.8538637",
"0.85172266",
"0.85172266",
"0.85172266",
"0.85172266",
"0.84925646",
"0.8484526",
"0.84638",
"0.84638",
"0.84638",
"0.84638",
"0.84638",
"0.84638",
"0.84638",
"0.84638",
"0.84638",
"0.84272957",
"0.84080255",
"0.8335764",
"0.8335764",
"0.8320428",
"0.8318789",
"0.8317669",
"0.83052385",
"0.8257962",
"0.8255938",
"0.8208822",
"0.817738",
"0.8161691",
"0.8148109",
"0.810042",
"0.8091887",
"0.80820435",
"0.80632144",
"0.8026374",
"0.78230196",
"0.78208387",
"0.7795015",
"0.7772358",
"0.77282995",
"0.7681813",
"0.75561744",
"0.7489923",
"0.7472866",
"0.7397747",
"0.7397747",
"0.7382134",
"0.7375977",
"0.7344767",
"0.7338564",
"0.73078024",
"0.7304434",
"0.7284278",
"0.7272675",
"0.726794",
"0.7228669",
"0.7208322",
"0.7193231",
"0.71789515",
"0.71490043",
"0.71004826",
"0.7097038",
"0.70378554",
"0.70292765",
"0.7021456",
"0.6999989",
"0.6962618",
"0.694068",
"0.6923482",
"0.6920072",
"0.691967",
"0.6899007",
"0.68962413",
"0.6893705",
"0.6886596",
"0.68753916",
"0.686252",
"0.68583435",
"0.6845051",
"0.6838373",
"0.68369126",
"0.6833708",
"0.68137765",
"0.67878413",
"0.6784392",
"0.6783771",
"0.67796534",
"0.6776695",
"0.67749995",
"0.67634344",
"0.6760999"
] |
0.7956138
|
44
|
test the is_leaf? method.
|
def test_is_leaf_eh
setup_test_tree
assert(!@child3.is_leaf?, "Child 3 is not a leaf node")
assert(@child4.is_leaf?, "Child 4 is a leaf node")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_leaf\n true\n end",
"def is_leaf\n true\n end",
"def is_leaf\n return @left == nil\n end",
"def leaf?\n true\n end",
"def leaf?\n !node?\n end",
"def is_a_leaf?\n self.left_child.nil? && self.right_child.nil?\n end",
"def is_leaf?\n self.children_count.zero?\n end",
"def is_leaf?\n self.left_child == nil and\n self.right_child == nil\n end",
"def leaf?; @leaf; end",
"def leaf?; false end",
"def leaf?\n leaves.count == 0\n end",
"def leaf?\n children.empty?\n end",
"def has_children?\n !leaf?\n end",
"def leaf?\n @children.empty?\n end",
"def is_leaf?\n\t\tself.part_map.empty?\n\tend",
"def children_are_leaves?\n unless leaf?\n @children[0].leaf?\n end\n end",
"def leaf?\n self.children.size == 0\n end",
"def leaf?\n level.zero?\n end",
"def leaf?\n @children.length.zero?\n end",
"def leaf?\n right - left == 1\n end",
"def leaf?(r)\n r.children.empty?\n end",
"def leaf_node?(node_id)\n @leaf_count < node_id\n end",
"def leaf?\n @succ.length == 0\n end",
"def leaf?\n new_record? || (rgt - lft == 1)\n end",
"def leaf?\n record.persisted? && if children.loaded? || tree.columns.counter_cache?\n # no SQL-queries here\n children.empty?\n else\n !children.exists?\n end\n end",
"def leaf?\n children.where(parent_id: self.id).empty?\n end",
"def leaf?\n persisted? && right.to_i - left.to_i == 1\n end",
"def leaf?(sexp)\n list?(sexp) && depth(sexp) == 1\nend",
"def leaf_node?(tree_node)\n tree_node.left.nil? && tree_node.right.nil?\nend",
"def leaf?\n left.nil? && right.nil?\n end",
"def leaf?(node)\n terminal?(node) && out_degree(node) == 0\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def assert_leaf(node)\n assert node.element_children.empty?, 'expected no children', node\n end",
"def leaf?\n persisted? && if children_counter_cache_column\n self[children_counter_cache_column] == 0\n else\n children.count == 0\n end\n end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def leaf?(term_or_go)\n go_id = as_term(term_or_go).id\n not_a_leaf = @terms.any? do |term| \n term.is_as.any? do |is_a_id| \n go_id == is_a_id\n end\n end\n !not_a_leaf\n end",
"def sub_branch?\n !root?\n end",
"def leaf_node?(index)\n return index >= @heap_size/2\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def _leaf(name, rx, ignorable: false, boundary: false, tests: [], preconditions: [], process: nil)\n raise Error, 'tests must be an array' unless tests.is_a? Array\n raise Error, 'preconditions must be an array' unless preconditions.is_a? Array\n\n init\n init_check(name)\n name = name.to_sym\n return if dup_check(:leaf, name, rx, tests + preconditions)\n\n tests << [process] if process\n @leaves << Leaf.new(name, rx, ignorable: ignorable, boundary: boundary, tests: tests, preconditions: preconditions)\n end",
"def empty?\n @root.empty? && @root.leaf?\n end",
"def leaf_version?\n\t\treturn self.child_versions.empty?\n\tend",
"def invalid_leaf?\n if valid_flag\n errors.add(:valid_flag, '契約中のリーフは削除できません。')\n return false\n end\n end",
"def leaf_node?(indx)\n return indx >= @heap_size/2\n end",
"def leaf?\n self.variations.size == 0\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def valid_tree?\n false\n end",
"def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def valid_tree?\n true\n end",
"def valid_tree?\n true\n end",
"def child?\n !root?\n end",
"def has_children?\n false\n end",
"def is_subtree(root)\n\nend",
"def has_children?(tree_node)\n tree_node.left || tree_node.right\n end",
"def valid_tree?\n true\n end",
"def test_leaves_works\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(40, \"movie b\")\n tree.insert(60, \"movie c\")\n tree.insert(45, \"movie d\")\n tree.insert(20, \"movie e\")\n tree.insert(55, \"movie f\")\n tree.insert(80, \"movie g\")\n assert_equal 4, tree.leaves\n end",
"def child?\n !root?\n end",
"def leaves?\n false\n end",
"def leaf(node, tag)\r\n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def leaf?\n (keys - [:name, :balance]).empty?\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def adjacent_leaves?(n,m)\n leaves.find_index(n.rightmost_leaf) == leaves.find_index(m.leftmost_leaf) - 1 \n end",
"def lowest_level?\n !children.any? {|child| child.kind_of?(NonLeafNode)}\n end",
"def has_children?\n !self.children.empty?\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n !children.empty?\n end",
"def leaves\n descendants.where(arel_table[is_leaf_column_name].eq(true))\n end",
"def find_leaf\n if first_question.descendants.length > 0\n leaves = first_question.descendants.select {|q| q.leaf?}\n\n raise StandardError, \"Multiple leaves found!\" if leaves.length > 1\n raise StandardError, \"No leaf found!\" if leaves.length == 0\n\n leaves.first\n else\n # Only one question!\n first_question\n end\n\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def children?\n !children.empty?\n end",
"def has_children?\n ( self[:has_children] == 1 )\n end",
"def child_of?(parent); end",
"def is_valid?\n leaf_nodes = each_leaf\n leaf_nodes.map(&:is_closed?).reduce(&:&)\n end",
"def losing_node?(evaluator) #mark\n # other_mark = @next_mover_mark == evaluator ? \n if @board.over? \n winner = @board.winner\n return winner && winner != evaluator\n else \n if evaluator == @next_mover_mark\n children.all?{|ele| ele.losing_node?(evaluator)}\n else \n children.any?{|ele| ele.losing_node?(evaluator)}\n end \n end \n\n end",
"def _is_root_node?\n @nodes.size == 1\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def children_exist?\n\tend",
"def has_parent?\n !root?\n end",
"def has_children?\n @nodes && !@nodes.empty?\n end",
"def is_child?\n !is_parent?\n end",
"def root?\n !has_parent?\n end",
"def have_children?\n children.count != 0\n end"
] |
[
"0.87861156",
"0.87861156",
"0.8582141",
"0.8375332",
"0.82717794",
"0.82253176",
"0.81750053",
"0.81031686",
"0.80189276",
"0.80012417",
"0.7976427",
"0.79656833",
"0.79433405",
"0.7925012",
"0.7893264",
"0.78806865",
"0.78794503",
"0.78500605",
"0.78383994",
"0.7787532",
"0.7785884",
"0.751771",
"0.74988997",
"0.74366677",
"0.7397823",
"0.73673546",
"0.7336271",
"0.7295007",
"0.7275007",
"0.72618437",
"0.7253656",
"0.71751934",
"0.71737164",
"0.7057516",
"0.7013765",
"0.6968478",
"0.6965218",
"0.68442667",
"0.6768627",
"0.67175066",
"0.6663686",
"0.66512614",
"0.6624947",
"0.65909576",
"0.6568211",
"0.65400004",
"0.65400004",
"0.64979136",
"0.6495503",
"0.6487248",
"0.6481539",
"0.6481539",
"0.6437356",
"0.6436522",
"0.64135474",
"0.6403458",
"0.63996315",
"0.6378333",
"0.6362462",
"0.636055",
"0.6347348",
"0.6335526",
"0.6335526",
"0.6335526",
"0.6335526",
"0.6327907",
"0.6317204",
"0.6291855",
"0.62699425",
"0.6260212",
"0.625098",
"0.625098",
"0.625098",
"0.625098",
"0.62308025",
"0.6228475",
"0.6223977",
"0.6198646",
"0.6198646",
"0.6188129",
"0.6178247",
"0.61723346",
"0.6170524",
"0.6169851",
"0.6162672",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61436677",
"0.61369526",
"0.6133685",
"0.61331433",
"0.6127338",
"0.6119911",
"0.61090046"
] |
0.8251714
|
5
|
Test the is_root? method.
|
def test_is_root_eh
setup_test_tree
assert(@root.is_root?, "The ROOT node must respond as the root node")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_root?\n false\n end",
"def root?\n root == self\n end",
"def has_root?\n @root != nil\n end",
"def root?\n root\n end",
"def root?\n true\n end",
"def root?\n true\n end",
"def root?\n true\n end",
"def is_root?\n \troot == id\n end",
"def root?\n @type == ROOT\n end",
"def root?\n false\n end",
"def root?\n false\n end",
"def root?\n ROOT == self\n end",
"def root?\n !has_parent?\n end",
"def is_root?() @name === '__root__'; end",
"def is_root?()\n @rootpath == @path\n end",
"def is_root?()\n return (name.nil? and parent.nil?) \n end",
"def is_root?\n return call_ancestry_method(:is_root?) if use_ancestry?\n\n rel = relationship # TODO: Handle a node that is a root and a node at the same time\n rel.nil? ? true : rel.is_root?\n end",
"def root?\n !parent\n end",
"def root?\n self.depth.zero?\n end",
"def root?\n self.depth.zero?\n end",
"def root?\n depth == 1\n end",
"def is_root?\n @parent.nil?\n end",
"def is_root?\n self.parent_id.nil?\n end",
"def root?\n id == Id::ROOT\n end",
"def root?\n self.class.roots.exists?(self.id)\n end",
"def is_root?\n parent_id.nil?\n end",
"def is_root?\n parent_id.nil?\n end",
"def test_root_setup\n assert_not_nil(@root , \"Root cannot be nil\")\n assert_nil(@root.parent , \"Parent of root node should be nil\")\n assert_not_nil(@root.name , \"Name should not be nil\")\n assert_equal(\"ROOT\" , @root.name, \"Name should be 'ROOT'\")\n assert_equal(\"Root Node\" , @root.content, \"Content should be 'Root Node'\")\n assert(@root.is_root? , \"Should identify as root\")\n assert(!@root.has_children? , \"Cannot have any children\")\n assert(@root.has_content? , \"This root should have content\")\n assert_equal(1 , @root.size, \"Number of nodes should be one\")\n assert_equal(0, @root.siblings.length, \"This root does not have any children\")\n assert_equal(0, @root.in_degree, \"Root should have an in-degree of 0\")\n assert_equal(0, @root.node_height, \"Root's height before adding any children is 0\")\n assert_raise(ArgumentError) { Tree::TreeNode.new(nil) }\n end",
"def enforce_root(root); end",
"def root?\n root_id.nil?\n end",
"def test_root\n setup_test_tree\n\n # TODO: Should probably change this logic. Root's root should\n # return nil so that the possibility of a recursive error does not exist\n # at all.\n assert_same(@root , @root.root, \"Root's root is self\")\n assert_same(@root , @child1.root, \"Root should be ROOT\")\n assert_same(@root , @child4.root, \"Root should be ROOT\")\n assert_equal(2 , @root.node_height, \"Root's height after adding the children should be 2\")\n end",
"def root?\n self.parent ? false : true\n end",
"def root?\n parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?\n is_root?(@path)\n end",
"def root?\n parent.on_node { |p| p }.nil?\n end",
"def root?\n parent.nil?\n end",
"def root?(node)\n in_degree(node) == 0 && out_degree(node) > 0\n end",
"def root?; end",
"def root?; end",
"def root?\n class_name == nil && method_name == nil\n end",
"def _is_root_node?\n @nodes.size == 1\n end",
"def root?\r\n\t\treturn parent == nil\r\n\tend",
"def root?\n self.parent.nil?\n end",
"def root?\n @parent.nil?\n end",
"def is_root?\n @path == '/' || @path == ''\n end",
"def root?\n @parent.nil?\n end",
"def root?\n parent.terminal?\n end",
"def root?\n self.path == '/'\n end",
"def root?\n !self.hier? || self.path == '/' || self.path.to_s.empty?\n end",
"def root?\n context.root_component == self\n end",
"def root?\n parent_id.nil?\n end",
"def root?\n parent_id.nil?\n end",
"def include_root?\n min_depth == 0\n end",
"def root?\n parent_id.nil?\n end",
"def root?\n parent_id.nil?\n end",
"def root?\n _parent_id.nil?\n end",
"def root?\n (@nv === 0) and (@dv === 1) and (@snv === 1) and (@sdv === 0)\n end",
"def root?\n parent_id = self[nested_set_parent]\n (parent_id == 0 || parent_id.nil?) && (self[nested_set_left] == 1) && (self[nested_set_right] > self[nested_set_left])\n end",
"def root_object?\n root_object == self\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def is_empty\n @root == nil\n end",
"def is_root_term?\n return false\n end",
"def empty?\n @root.nil?\n end",
"def empty?\n @root.nil?\n end",
"def check_for_root\n if taxonomy.try(:root).present? && parent_id.nil?\n errors.add(:root_conflict, 'this taxonomy already has a root taxon')\n end\n end",
"def root? # :nodoc:\n not (id =~ ROOT_ID_REGEXP).nil?\n end",
"def child?\n !root?\n end",
"def root?\n #%r{\\A/+\\z} =~ @path ? true : false\n @absolute and @path.empty?\n end",
"def root?\n !!@root || app_file?\n end",
"def child?\n !root?\n end",
"def empty?\n root.nil?\n end",
"def check\n errors.add :root, \"Must have a root node\" if root_id.nil?\n end",
"def root?\n self[tree_parent_id_field].nil?\n end",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def empty?\n @root.empty? && @root.leaf?\n end",
"def has_parent?\n !root?\n end",
"def is_root?( inventory )\n\t\tinventory.template_root?( @id )\n\tend",
"def root?\n prev.nil? && self.next.nil?\n end",
"def is_chain_select_root?\n self.chain_select_root\n end",
"def root?\n return @active_context.empty?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def parent?\n !root?\n end",
"def get_root()\n \n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def fetch_root(key)\n return true if key == root.hash\n\n root = fetch_node_nt(key)\n return false unless root\n\n @root = root\n return true\n end",
"def root_private?\n self.root.private?\n end",
"def root?\n \tfolder_id.nil?\n end",
"def _is_root?\n !@parent.is_a?(BaseEndpoint)\n end",
"def root?\n parent_id = self[acts_as_nested_set_options[:parent_column]]\n (parent_id == 0 || parent_id.nil?) && (self[acts_as_nested_set_options[:left_column]] == 1) && (self[acts_as_nested_set_options[:right_column]] > self[acts_as_nested_set_options[:left_column]])\n end",
"def root?\n subject == :_ && predicate == :_ && object == :_\n end",
"def root?\n self[parent_column].nil?\n end",
"def is_valid_BST?(root)\n min = -Float::Infinity\n max = Float::Infinity \n return is_valid_helper(root, min, max)\nend",
"def root?\n @uid || @uid = fetch_uid\n end",
"def is_root_site?\n @depth == 0\n end"
] |
[
"0.82637626",
"0.81894755",
"0.8150901",
"0.81488985",
"0.805424",
"0.8050058",
"0.8050058",
"0.8029191",
"0.7975747",
"0.7963455",
"0.7958967",
"0.7940238",
"0.77978915",
"0.7666345",
"0.76224166",
"0.7549867",
"0.7534729",
"0.7499187",
"0.7497382",
"0.7497382",
"0.7478093",
"0.74683255",
"0.7466536",
"0.7433662",
"0.74250805",
"0.74083704",
"0.74083704",
"0.73917884",
"0.73771554",
"0.7360904",
"0.7344328",
"0.7337355",
"0.7323242",
"0.7323242",
"0.7323242",
"0.7323242",
"0.73132163",
"0.7301329",
"0.72775537",
"0.72764194",
"0.72756827",
"0.72756827",
"0.7258402",
"0.7244462",
"0.7233572",
"0.7159464",
"0.7150034",
"0.71447414",
"0.71346843",
"0.70854884",
"0.7077727",
"0.7059322",
"0.70398843",
"0.70037395",
"0.70037395",
"0.70027506",
"0.69960505",
"0.69923973",
"0.6975632",
"0.69477767",
"0.6944388",
"0.692338",
"0.6918067",
"0.6918067",
"0.6917065",
"0.6873826",
"0.6858297",
"0.6857188",
"0.68535787",
"0.6847031",
"0.68221796",
"0.6733648",
"0.672945",
"0.67270386",
"0.6724585",
"0.6692339",
"0.6687241",
"0.6680109",
"0.66425055",
"0.6640732",
"0.6628569",
"0.65985954",
"0.6584267",
"0.6556146",
"0.64956266",
"0.64956266",
"0.64956266",
"0.64929724",
"0.6471105",
"0.6463531",
"0.6452417",
"0.6447241",
"0.6421653",
"0.6393232",
"0.63887316",
"0.63653874",
"0.635777",
"0.63389236",
"0.63121974",
"0.62843764"
] |
0.83728653
|
0
|
Test the content= method.
|
def test_content_equals
@root.content = nil
assert_nil(@root.content, "Root's content should be nil")
@root.content = "ABCD"
assert_equal("ABCD", @root.content, "Root's content should now be 'ABCD'")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def content=(content)\n @content = content\n end",
"def setContent(content)\r\n\t\t\t\t\t@content = content\r\n\t\t\t\tend",
"def setContent(content)\r\n\t\t\t\t\t@content = content\r\n\t\t\t\tend",
"def set_content(content)\n @content = content\n end",
"def content= (new_content)\n @content = new_content\n end",
"def content=(value)\n @content = value\n end",
"def content=(value)\n @content = value\n end",
"def content=(value)\n @content = value\n end",
"def content=(value)\n @content = value\n end",
"def content=(value)\n @content = value\n end",
"def content=(value)\n @content = value\n end",
"def content=(v)\n @content = v\n end",
"def content=(string); end",
"def content=(string); end",
"def content=(_); end",
"def setContent(value) \n @obj.setContent(value) \n end",
"def content=(content)\n if content.nil?\n fail ArgumentError, 'invalid value for \"content\", content cannot be nil.'\n end\n @content = content\n end",
"def content=(new_content)\n @content = new_content\n end",
"def test_get_content_for\n end",
"def content \n @content\n end",
"def content\n @content ||= params['content']\n end",
"def content\n @content\n end",
"def content\n @content\n end",
"def content\n\t\t@content\n\tend",
"def content\n end",
"def content\n end",
"def content\n end",
"def content\n @content \n end",
"def content= content\n @file = content\n @content = content.dup\n @content &&= @content.read if @content.respond_to? :read\n @content &&= @content.to_s if @content.respond_to? :read\n end",
"def content=(content)\n @mime = @metadata = nil\n @content = content\n end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def set_content\n\t @content = Content.find(params[:id])\n\tend",
"def content\n @content ||= content!\n end",
"def content_data=(value)\n @content_data = value\n end",
"def content_data=(value)\n @content_data = value\n end",
"def test_get_page_content\r\n t = AuthorInfo.get_page({\"parse\" => {\"text\" => {\"*\" => \"some content\"}}})\r\n assert_equal(true, t === \"some content\")\r\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def content=(_arg0); end",
"def content=(_arg0); end",
"def content=(_arg0); end",
"def content=(_arg0); end",
"def content=(_arg0); end",
"def content=(_arg0); end",
"def set_content\n @content = Content.find(params.require(:content_id))\n end",
"def content=(value)\n return if value == self.content\n self.add_current_locale\n self.default_content = false\n super\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def content=(new_content)\n @content = (new_content.is_a?(Content) ? new_content : Content.new(new_content))\n end",
"def content\n text\n end",
"def contents\n self.content\n end",
"def with_content(content)\n @content = content\n self\n end",
"def content\n @content\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def test_content\n pers = Person::new(\"John\", \"Doe\")\n @root.content = pers\n assert_same(pers, @root.content, \"Content should be the same\")\n end",
"def test_content_cached_on_access\n page = new_page()\n page.content = 'This is a test'\n # No content yet\n assert_nil page.content_cache\n # Calling #content_html triggers HTML generation\n assert_not_nil page.content_html\n assert_not_nil page.content_cache\n end",
"def content_from_default=(content)\n # needs to be overridden for each kind of elements\n end",
"def content\n raise \"Must be implemented.\" \n end",
"def content\n nil\n end",
"def set_content(content)\n if NOKOGIRI\n @xml.content = content\n else\n @xml.text = content\n end\n end",
"def content=(content)\n @buffer = content || \"\"\n @size = content.nil? ? nil : content.size\n end",
"def test_content_cached_on_save\n page = new_page()\n page.content = 'This is a test'\n # No content yet\n assert_nil page.content_cache\n page.save\n # Saving triggers HTML generation\n assert_not_nil page.content_cache\n end",
"def content\n object = FakeObject.new\n end",
"def content_manipulation\n self.summary = markup_manipulation self.summary if self.summary.present?\n self.content = markup_manipulation self.content if self.content.present?\n end",
"def content\n raise 'You must implement #content'\n end",
"def content_info=(value)\n @content_info = value\n end",
"def content!\n @raw = nil # force to reload it\n self.content\n end",
"def default_content; end",
"def set_content\n @o_single = Content.find(params[:id])\n end",
"def content\n try(content_type)\n end",
"def set_PostContent(value)\n set_input(\"PostContent\", value)\n end",
"def set_PostContent(value)\n set_input(\"PostContent\", value)\n end",
"def getContent\r\n\t\t\t\t\treturn @content\r\n\t\t\t\tend",
"def getContent\r\n\t\t\t\t\treturn @content\r\n\t\t\t\tend",
"def preview_content=(content)\n @mime = nil\n @content = content\n end",
"def content\n if @content.respond_to?(:call)\n @content = @content.call\n else\n @content\n end\n end",
"def simple_content_assert(exp_val, inp_val)\n exp_hash = {}\n exp_hash['subject'] = exp_val unless exp_val.nil?\n exp_hash['content'] = exp_val unless exp_val.nil?\n exp = expected_response exp_hash\n assert_equal exp, ApiParser.parse_email(nil, nil, nil, nil, inp_val, inp_val)\n end",
"def content?\n !content.nil? && !content.empty?\n end",
"def content\n @content ||= case\n when @file\n @file.read\n when @text\n @text\n when @url\n raise URI::InvalidURIError, @url unless @url =~ URI::regexp\n response = open(@url)\n html = response.read\n html.encode(\"UTF-16\", \"UTF-8\", :invalid => :replace, :replace => \"\").encode(\"UTF-8\", \"UTF-16\")\n end\n end",
"def sync\n #debug 'content sync'\n # We're safe not testing for the 'source' if there's no 'should'\n # because we wouldn't have gotten this far if there weren't at least\n # one valid value somewhere.\n @resource.write(:content)\n end"
] |
[
"0.74305713",
"0.73660016",
"0.73660016",
"0.7365818",
"0.73488307",
"0.73015845",
"0.73015845",
"0.73015845",
"0.73015845",
"0.73015845",
"0.73015845",
"0.71943",
"0.710825",
"0.710825",
"0.70657825",
"0.7027108",
"0.70021707",
"0.69263816",
"0.67569983",
"0.675478",
"0.6722968",
"0.6675256",
"0.6675256",
"0.66327566",
"0.66176844",
"0.66176844",
"0.66176844",
"0.65933764",
"0.65687263",
"0.6568154",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.65612096",
"0.6539249",
"0.6498065",
"0.64828646",
"0.64828646",
"0.64402944",
"0.6437075",
"0.6437075",
"0.6437075",
"0.6437075",
"0.64296985",
"0.64296985",
"0.64296985",
"0.64296985",
"0.64296985",
"0.64296985",
"0.6415471",
"0.6409452",
"0.6403878",
"0.6403878",
"0.6403878",
"0.6403878",
"0.6403878",
"0.6403878",
"0.6403878",
"0.6385334",
"0.6379352",
"0.63635015",
"0.63567066",
"0.6322135",
"0.631763",
"0.6306256",
"0.62921536",
"0.6280223",
"0.62561965",
"0.6234757",
"0.6203036",
"0.6185217",
"0.61271137",
"0.611875",
"0.6111918",
"0.6094204",
"0.6083988",
"0.60780174",
"0.6068925",
"0.6048215",
"0.6038599",
"0.60368776",
"0.60368776",
"0.6036484",
"0.6036484",
"0.60274",
"0.6014715",
"0.60097706",
"0.60080487",
"0.60017896",
"0.60005116"
] |
0.65447176
|
44
|
Test the size method.
|
def test_size
assert_equal(1, @root.size, "Root's size should be 1")
setup_test_tree
assert_equal(5, @root.size, "Root's size should be 5")
assert_equal(2, @child3.size, "Child 3's size should be 2")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size(*) end",
"def size(*) end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n\n end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def test_size\r\n assert_respond_to(File, :size)\r\n assert_equal(17, File.size(@file))\r\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size; @size end",
"def size\n @size \n end",
"def size\n @size \n end",
"def size\nend",
"def size\n end",
"def size\n raise NotImplementedError\n end",
"def size\n\n\n end",
"def size?() end",
"def test_length_is_size\n setup_test_tree\n assert_equal(@root.size, @root.length, \"Length and size methods should return the same result\")\n end",
"def size\n raise NotImplementedError\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size\n\tend",
"def size\n raise Exception.new(\"This should be subclassed.\")\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size.size\n end",
"def size\n # returns the value of the instance var @size\n @size\n # end of size method\n end",
"def size\n raise NotImplementedError.new\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n \t@size\n end",
"def size\n # return the value of the instance variable @size\n @size\n # end size method\n end",
"def get_size\n\t\tend",
"def size\n @size\n end",
"def size\n return @size\n end",
"def size\n return @size\n end",
"def size\n length\n end",
"def size\n tests.size\n end",
"def test_size\n assert_equal(3, @list.size)\n end",
"def size\n @size\n end",
"def size()\n #YOUR WORK HERE\n end",
"def test_deck_size_fullDeck\n deck = Deck.new\n assert_equal(81, deck.size, \"Expected size of 81.\")\n end"
] |
[
"0.78845096",
"0.78845096",
"0.78845096",
"0.78845096",
"0.78845096",
"0.78845096",
"0.785843",
"0.785843",
"0.78399026",
"0.78399026",
"0.78399026",
"0.78007126",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.77779907",
"0.7725773",
"0.77106565",
"0.77106565",
"0.77106565",
"0.77106565",
"0.77106565",
"0.77106565",
"0.77106565",
"0.7689473",
"0.7689473",
"0.7684656",
"0.7661118",
"0.7661118",
"0.7655743",
"0.7629919",
"0.75622153",
"0.7561029",
"0.7560067",
"0.7556185",
"0.7526167",
"0.7523084",
"0.7520966",
"0.7520966",
"0.7482112",
"0.7478105",
"0.7471256",
"0.7471256",
"0.7471256",
"0.7469943",
"0.7469912",
"0.7456999",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.7456883",
"0.74448985",
"0.7408163",
"0.73706025",
"0.73481864",
"0.73479825",
"0.73479825",
"0.7325813",
"0.7320864",
"0.7306575",
"0.73038256",
"0.72883236",
"0.7254187"
] |
0.76174635
|
48
|
Test the << method.
|
def test_lt2 # Test the << method
@root << @child1
@root << @child2
@root << @child3 << @child4
assert_not_nil(@root['Child1'], "Child 1 should have been added to Root")
assert_not_nil(@root['Child2'], "Child 2 should have been added to Root")
assert_not_nil(@root['Child3'], "Child 3 should have been added to Root")
assert_not_nil(@child3['Child4'], "Child 4 should have been added to Child3")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def <<(x) end",
"def <<(x) end",
"def <<\n end",
"def <<\n end",
"def <<\n end",
"def <<(value); end",
"def <<(arg); end",
"def <<(data); end",
"def <<(data); end",
"def <<(data); end",
"def <<(data); end",
"def <<(data)\n end",
"def <<(arg0)\n end",
"def <<(arg0)\n end",
"def <<(arg0)\n end",
"def <<(arg0)\n end",
"def <<(to_append); end",
"def test_write\n write_message(:todo, \"Hey, it worked\")\n end",
"def <<(object)\n # TODO\n end",
"def <<(reporter); end",
"def <<(msg) debug(msg); end",
"def <<(node); end",
"def <<(string); end",
"def <<(string); end",
"def <<(work); end",
"def <<(work); end",
"def write; end",
"def write; end",
"def <<\n puts @str\n end",
"def <<(arg); add(*arg); end",
"def <<(message)\n debug message\n end",
"def <<(child); end",
"def <<(p0) end",
"def <<(p0) end",
"def <<(p0) end",
"def <<(p0) end",
"def <<(node); add(node); end",
"def << string\n #This is a stub, used for indexing\n end",
"def << string\n #This is a stub, used for indexing\n end",
"def << (arg)\n super(arg)\n end",
"def <<(item)\n add!(item)\n end",
"def <<(s)\n puts s if @verbose\n @report << s\n end",
"def write\n end",
"def test_concatenation_operator\n assert_respond_to @v, :>>\n assert_equal MyVector[1,2,4], @v << 4\n end",
"def test_normal_append\n @store.set(@key, @flag, @exp_time, @size, @value, @no_reply)\n\n assert_equal(STORED, @store.append(@key, @size_append, @value_append, @no_reply), STORED_MESSAGE)\n end",
"def << message; write UNKNOWN, message, caller[0] end",
"def write?; end",
"def write?; end",
"def write?; end",
"def test_report_event\r\n assert_respond_to(@log, :report_event)\r\n assert_respond_to(@log, :write) # alias\r\n assert_raises(ArgumentError){ @log.report_event }\r\n end",
"def <<(elemento)\n end",
"def <<(obj)\n raise Error::TypeError\n end",
"def test_it_can_save_input_to_output\n night_writer = NightWriter.new\n night_writer.save_input_to_output\n\n assert_equal \"hello world\\n\", night_writer.read_output\n end",
"def <<(buf)\n return write(buf.to_s)\n end",
"def >> (other)\n other << self\n end",
"def <<(msg = T.unsafe(nil)); end",
"def log_writer; end",
"def writethis; end",
"def todo\n flunk \"test not written\"\n end",
"def <<(data)\r\n @data << data\r\n end",
"def test_array_append\n array = [1,2,3,4,5]\n array = array << 99\n assert_equal [1,2,3,4,5,99], array\n end",
"def <<(obj)\n check(obj)\n super\n end",
"def write!(_)\n raise NotImplementedError, 'Implement #write! in child class'\n end",
"def <<(data)\n write(data)\n self\n end",
"def write(*args)\n @writer.<<(*args) if @writer\n end",
"def writer; end",
"def <<(value)\n add(value)\n end",
"def <<(rule); end",
"def <<(*args)\n insert(*args)\n end",
"def << toadd\n# puts \"type: #{toadd.class}\"\n case toadd\n when Array\n# puts \"recognised array\"\n toadd.each do |ta| \n r = add_single ta\n raise \"This type is not recongnised.\" if r ==false\n end\n else\n r=add_single toadd\n raise \"This type is not recongnised.\" if r==false\n end\n self\n end",
"def << (s)\n do_write(s)\n self\n end",
"def <<(msg)\n @logdev.write(msg) if @logdev\n end",
"def test_shovel \r\n new_todo = Todo.new('Walk the dog')\r\n @list << new_todo# TodoList object\r\n @todos << new_todo # array of Todo objects\r\n\r\n assert_equal(@todos, @list.to_a)\r\n end",
"def <<(string)\n self.term(string)\n\n self.results :print => true\n end",
"def write\n raise \"Writers must implement #write\"\n end",
"def testing\n # ...\n end",
"def test_writing\n assert_raises( SugarException ) {\n sugar = Sugar.new()\n sugar.sequence\n }\n \n sugar = Sugar.new()\n\t\tsugar.extend( Sugar::IO::CondensedIupac::Builder )\n\t\tsugar.extend( Sugar::IO::CondensedIupac::Writer )\n sugar.sequence = LARGE_STRUCTURE\n \n assert_equal( LARGE_STRUCTURE, sugar.sequence)\n \n assert_nothing_raised {\n sugar = Sugar.new()\n\t\t\tsugar.extend( Sugar::IO::CondensedIupac::Builder )\n\t\t\tsugar.extend( Sugar::IO::CondensedIupac::Writer )\n sugar.sequence = IUPAC_DISACCHARIDE\n sugar.target_namespace = NamespacedMonosaccharide::NAMESPACES[:dkfz]\n }\n sugar = Sugar.new()\n sugar.extend( Sugar::IO::CondensedIupac::Builder )\n sugar.extend( Sugar::IO::GlycoCT::Writer )\n sugar.sequence = LARGE_STRUCTURE\n sugar.target_namespace = :ecdb\n assert_equal( LARGE_STRUCTURE_AS_CT, sugar.sequence)\n\n end",
"def test_shovel_integer_into_vector\n\n assert_respond_to @a, :<<\n assert_equal(My_Vector[1,2,3], @a << 3)\n end",
"def <<(d)\n @writer << d\n self\n end",
"def test_0050_shift_method\n @@log.debug \"test_0050_shift_method starts\" if @@log.debug?\n assert_equal(@aen, @list.shift)\n assert_equal(@bsb, @list.shift)\n assert_equal(@cab, @list.shift)\n assert_equal(@dad, @list.shift)\n assert_nil(@list.shift)\n @@log.debug \"test_0050_shift_method ends\" if @@log.debug?\n end",
"def <<(*args)\n @io << args\n return self\n end",
"def <<(node_or_tags); end",
"def <<(node_or_tags); end",
"def write_test(resource = nil)\n if resource.action.is_a? Array\n return if resource.action.include?(:delete)\n end\n return if resource.action == :delete\n\n \"\\n\" + send(\"test_#{resource.declared_type}\", resource)\n end",
"def <<(value)\n push(value)\n end",
"def <<(string)\n\t\t\t\twrite(string)\n\t\t\t\t\n\t\t\t\treturn self\n\t\t\tend",
"def write\n write_data\n end",
"def <<(obj)\n each_ios_and_stdout(obj, &:<<)\n end",
"def test_append_method\n list = LinkedList.new\n\n list.append(\"West\", {\"pounds of food\" => 200})\n\n assert_instance_of Node, list.head\n assert_equal \"West\", list.head.surname\n end",
"def docs_to_write; end",
"def <<(*args)\n self + args\n end",
"def test_basic_create\n id_ = @logger.begin_record\n @logger.end_record\n record_ = @records.dequeue\n assert(record_.started?)\n assert(record_.complete?)\n assert_equal(id_, record_.record_id)\n assert_equal(0, record_.message_count)\n assert_equal(2, record_.entry_count)\n entries_ = record_.all_entries\n assert_equal(:begin_record, entries_[0].type)\n assert_equal(@levels.get(:ANY), entries_[0].level)\n assert_equal('sawmill', entries_[0].progname)\n assert_equal(id_, entries_[0].record_id)\n assert_equal(:end_record, entries_[1].type)\n assert_equal(@levels.get(:ANY), entries_[1].level)\n assert_equal('sawmill', entries_[1].progname)\n assert_equal(id_, entries_[1].record_id)\n end",
"def write(value)\n # pass\n end",
"def <<(tag)\n add(tag)\n end",
"def assertions; end",
"def assertions; end",
"def write(entry)\n raise NotImplementedError\n end",
"def write(entry)\n raise NotImplementedError\n end",
"def test_appends\n\n # Try editing without logging in.\n put(:append, {}, {})\n assert_redirected_to(:controller => 'user', :action => 'login')\n\n # Try editing from a non-Admin account.\n post(:append, {}, rich_designer_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n #assert_equal(Pcbtr::MESSAGES[:admin_only], flash['notice'])\n\n # Try editing from an Admin account\n post(:append, {:id => checks(:check_01).id}, cathy_admin_session)\n assert_response 200\n assert_equal(checks(:check_01).subsection_id, assigns(:new_check).subsection_id)\n assert_equal(checks(:check_01).check_type, assigns(:new_check).check_type)\n\n end",
"def write(arg0)\n end"
] |
[
"0.70901245",
"0.70901245",
"0.7074061",
"0.7074061",
"0.7074061",
"0.6902383",
"0.6901677",
"0.67635036",
"0.67635036",
"0.67635036",
"0.67635036",
"0.6688614",
"0.6573168",
"0.6573168",
"0.6573168",
"0.6573168",
"0.64573646",
"0.64489645",
"0.639959",
"0.63786876",
"0.63700074",
"0.63689333",
"0.63598716",
"0.63598716",
"0.60698867",
"0.60698867",
"0.6032238",
"0.6032238",
"0.5985993",
"0.59661597",
"0.59265006",
"0.5907599",
"0.5897022",
"0.5897022",
"0.5897022",
"0.5897022",
"0.5894036",
"0.58869225",
"0.58869225",
"0.5876724",
"0.58525074",
"0.5844804",
"0.58264345",
"0.580292",
"0.57849604",
"0.57818526",
"0.57651794",
"0.57651794",
"0.57651794",
"0.5650579",
"0.56473833",
"0.5642731",
"0.5634924",
"0.5627347",
"0.56119156",
"0.5600753",
"0.55830926",
"0.5562605",
"0.55489254",
"0.55487597",
"0.55307096",
"0.55156404",
"0.55115217",
"0.55031997",
"0.5470207",
"0.5468011",
"0.5464564",
"0.54644537",
"0.5460772",
"0.5440208",
"0.53981155",
"0.5394131",
"0.5386959",
"0.53758425",
"0.5338409",
"0.5335144",
"0.5327011",
"0.5301261",
"0.5297423",
"0.52890605",
"0.52816707",
"0.5272057",
"0.5272057",
"0.5266188",
"0.52636135",
"0.5255934",
"0.5253251",
"0.52329296",
"0.52245754",
"0.52235293",
"0.5216381",
"0.521547",
"0.52062476",
"0.52020276",
"0.51937604",
"0.51937604",
"0.51870936",
"0.51870936",
"0.5161663",
"0.51450616"
] |
0.6294255
|
24
|
Test the [] method.
|
def test_index # Test the [] method
assert_raise(ArgumentError) {@root[nil]}
@root << @child1
@root << @child2
assert_equal(@child1.name, @root['Child1'].name, "Child 1 should be returned")
assert_equal(@child1.name, @root[0].name, "Child 1 should be returned")
assert_equal(@child1.name, @root[-2].name, "Child 1 should be returned") # Negative access also works
assert_equal(@child1.name, @root[-(@root.children.size)].name, "Child 1 should be returned") # Negative access also works
assert_equal(@child2.name, @root['Child2'].name, "Child 2 should be returned")
assert_equal(@child2.name, @root[1].name, "Child 2 should be returned")
assert_equal(@child2.name, @root[-1].name, "Child 2 should be returned") # Negative access also works
assert_nil(@root['Some Random Name'], "Should return nil")
assert_nil(@root[99], "Should return nil")
assert_nil(@root[-(@root.children.size+1)], "Should return nil")
assert_nil(@root[-3], "Should return nil")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [](*)\n raise NotImplementedError, '`#[]` method must be implemented'\n end",
"def [](index); end",
"def [](index)\n end",
"def [](index)\n end",
"def [](*) end",
"def [](index) # i.e. array style index lookup.\n end",
"def [](index); @data[index]; end",
"def [](value); end",
"def []( * ) # :nodoc:\n\t\treturn nil\n\tend",
"def [](param); end",
"def [](p1)\n #This is a stub, used for indexing\n end",
"def [](arg)\n end",
"def [](i)\n end",
"def [](i)\n end",
"def [](p1)\n #This is a stub, used for indexing\n end",
"def [](arg0)\n end",
"def [](expression); end",
"def [](*rest) end",
"def [](*rest) end",
"def [](p0) end",
"def [](p0) end",
"def [](posicion)\n end",
"def [](index)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def [] index\r\n @list[index]\r\n end",
"def test_0030_index_method\n @@log.debug \"test_0030_index_method starts\" if @@log.debug?\n # <<'s done in setup\n assert_equal(@aen,@list[0])\n assert_equal(@bsb,@list[1])\n assert_equal(@cab,@list[2])\n assert_equal(@dad,@list[3])\n #\n assert_nil(@list[9])\n @@log.debug \"test_0030_index_method ends\" if @@log.debug?\n end",
"def aget(index)\n end",
"def [](name); end",
"def [](name); end",
"def [](name); end",
"def [](name); end",
"def [](name); end",
"def [](index)\n self.__getitem__ index\n end",
"def test_index_access\n with_a_collection do\n assert_equal(@coll.first, @coll[0])\n end\n end",
"def [](idx)\n Ruby.primitive :array_aref\n end",
"def [](index)\n raise NoMethodError, %(this method must be redefined in subclasses)\n end",
"def [](p0, *rest) end",
"def [](p0, *rest) end",
"def [](*args)\n self\n end",
"def [](key)\n end",
"def [](key)\n end",
"def [](what)\n nil\n end",
"def [](key) ; @data[key] ; end",
"def get(index)\n \n end",
"def [](i); @x[i]; end",
"def access(n)\n true\n end",
"def [](index)\n return get(index)\n end",
"def [](index, name = T.unsafe(nil)); end",
"def [] (key)\n get(key)\n end",
"def [](name)\n\n end",
"def test_Arithmetic_Sample06\n assert_equal(1, 123[0])\n # TODO assert_equal(20, 123[3])\n # TODO assert_equal(3, 123[2])\n end",
"def []( index )\n feedme while !@done and index >= @truth.size\n return @truth[index]\n end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def test_array_index_0_equals_1\n\t\tassert_equal(1, anna_3_5[0])\n\tend",
"def [](index)\n get(index)\n end",
"def []=(*)\n raise NotImplementedError, '`#[]=` method must be implemented'\n end",
"def [](idx)\n send(idx)\n end",
"def [](index)\n set?(index)\n end",
"def test_arrayget_nil_on_nonexistent_index\n collection = Sketchup.active_model.pages\n expected = nil\n result = collection[collection.size]\n assert_equal(expected, result,\n 'Expected does not match result.')\n end",
"def [](index); @args[index] end",
"def [](index_or_name)\n end",
"def [](index_or_name)\n end",
"def [](index)\n all[index]\n end",
"def [](index)\n demand super(index)\n end",
"def [](key)\n puts \"STUB: [] in CacheMethods::Cache\"\n end",
"def [](sel); end",
"def [](n)\n @data[n]\n end",
"def [](index)\n @val[index]\n end",
"def test_14a_index_of_first_item\n puts \"test_14a_index_of_first_item\"\n ll = LinkedList.new()\n ll.push(\"foo\")\n ll.push(\"bar\")\n ll.push(\"good\")\n assert_equal(0, ll.index(\"foo\"))\n end",
"def [](index)\n cast get(index)\n end",
"def [](arg0, arg1, *rest)\n end",
"def [](*params)\n call(*params)\n end",
"def [](key, pos= 0, len= -1)\n end",
"def [](k) \n @data[k] \n end",
"def [](index)\n self.fetch[index]\n end",
"def at(index); end",
"def [](x)\n @data[x]\n end",
"def d\r\n a = [1, 2, 1.0]\r\n a[2]\r\nend",
"def [](i)\n \t@vector[i] \n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](*args) # :nodoc:\n call(*args)\n end",
"def test_instance_basic\n assert_equal('1', @ab[0])\n assert_equal('Assign', @ab[2])\n assert_equal('Buzz', @ab[4])\n assert_equal('AssignBuzz', @ab[14])\n assert_equal(nil, @ab[15])\n assert_equal(\n %w[1 2 Assign 4 Buzz\n Assign 7 8 Assign Buzz\n 11 Assign 13 14 AssignBuzz], @ab.results\n )\n assert_equal(3, @ab.Assign)\n assert_equal(5, @ab.Buzz)\n end"
] |
[
"0.7014241",
"0.70027465",
"0.69269663",
"0.69269663",
"0.68697435",
"0.68673015",
"0.6831208",
"0.6826385",
"0.6795721",
"0.6762816",
"0.6737938",
"0.67096496",
"0.6708499",
"0.6708499",
"0.6702766",
"0.66576606",
"0.66186357",
"0.6604641",
"0.6604641",
"0.6590126",
"0.6590126",
"0.6439321",
"0.6378111",
"0.6354464",
"0.63106775",
"0.62988263",
"0.62468797",
"0.62468797",
"0.62468797",
"0.62468797",
"0.62468797",
"0.6236415",
"0.6236195",
"0.62177193",
"0.6146956",
"0.61434335",
"0.61434335",
"0.6143319",
"0.6130621",
"0.6130621",
"0.6125434",
"0.6123547",
"0.61154455",
"0.61017823",
"0.6069906",
"0.6058272",
"0.60580194",
"0.6055852",
"0.6053",
"0.60511583",
"0.6051095",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.6050105",
"0.60335386",
"0.60297453",
"0.6016762",
"0.6007413",
"0.59956884",
"0.59684175",
"0.5964938",
"0.59337366",
"0.59337366",
"0.59293103",
"0.59223634",
"0.59194213",
"0.5918228",
"0.5906068",
"0.58943003",
"0.58931357",
"0.589181",
"0.5876955",
"0.58672416",
"0.5851452",
"0.5847699",
"0.5845913",
"0.58314896",
"0.5823622",
"0.581685",
"0.5802881",
"0.57913697",
"0.57913697",
"0.57913697",
"0.57913697",
"0.5790437",
"0.57876974"
] |
0.61459357
|
35
|
Test the in_degree method.
|
def test_in_degree
setup_test_tree
assert_equal(0, @root.in_degree, "Root's in-degree should be zero")
assert_equal(1, @child1.in_degree, "Child 1's in-degree should be 1")
assert_equal(1, @child2.in_degree, "Child 2's in-degree should be 1")
assert_equal(1, @child3.in_degree, "Child 3's in-degree should be 1")
assert_equal(1, @child4.in_degree, "Child 4's in-degree should be 1")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def degree(v) in_degree(v); end",
"def in_degree(vertex)\n\tend",
"def degree\n self.in_degree + self.out_degree\n end",
"def test_out_degree\n setup_test_tree\n\n assert_equal(3, @root.out_degree, \"Root's out-degree should be 3\")\n assert_equal(0, @child1.out_degree, \"Child 1's out-degree should be 0\")\n assert_equal(0, @child2.out_degree, \"Child 2's out-degree should be 0\")\n assert_equal(1, @child3.out_degree, \"Child 3's out-degree should be 1\")\n assert_equal(0, @child4.out_degree, \"Child 4's out-degree should be 0\")\n end",
"def degree; end",
"def inDegree( name )\n\tcount = 0\n if vertex?( name )\n\t\t@vertices.each_key{ |key| if edge?( key, name ) then count += 1 end}\n\tend\n\treturn count\n end",
"def in_degree(node)\n @pred[node].length\n end",
"def degree(node)\n in_degree(node) + out_degree(node)\n end",
"def in_degree(node)\n self[node].length\n end",
"def out_degree(vertex)\n\tend",
"def inDegree( name )\n\t\n\tcount = 0\n if @vertices.has_key? name\n\t @vertices.each { |key,v| count+=1 if self.edge?(key,name) }\n\t end\n\treturn count\n end",
"def in_degree(v)\n r = 0\n each_in_neighbor(v) { |u| r += 1 }\n r\n end",
"def outDegree( name )\n\tif vertex?( name )\n\t\treturn @vertices[ name ].size\n\tend\n\treturn 0\n end",
"def outDegree( name )\n if (@vertices.has_key? name)\n\t\treturn @vertices[name].size\n\telse\n\t\treturn 0\n\tend\n end",
"def in_degree\n @in_edges.length\n end",
"def offer_degree?\n institution_of_higher_learning_indicator || non_college_degree_indicator\n end",
"def degree(v)\n in_degree(v) + out_degree(v)\n end",
"def get_in_degrees(graph)\n in_degrees = {}\n graph.keys.each { |vtx| in_degrees[vtx] = 0 }\n graph.values.each do |neighbors|\n neighbors.each do |neighbor|\n in_degrees[neighbor] += 1\n end\n end\n in_degrees\nend",
"def imperfect_degrees degree\n # remember: a third from degree is (degree + 2)\n candidates = [degree - 5, degree - 2, degree + 2, degree + 5].reject{|d| d < 1}\n imperfect = candidates.select{ |cd| [-9, -8, -4, -3, 3, 4, 8, 9].include?(at(cd) - at(degree))}\n end",
"def test_correcto\n\t\tassert_equal(12, @circle.rad(75.36) )\n\tend",
"def out_degree(v)\n r = 0\n each_adjacent(v) { |u| r += 1 }\n r\n end",
"def degree(vertex)\n\tend",
"def find_degrees_edges\n raise RuntimeError, \"Call filter_graph_by_users before find_degrees\" unless File.exist? @graph_filename\n \n # Open graph file and read in undirected edges\n puts \"Reading in edges from graph & calculating in/outdegree...\"\n edges = {}\n degrees = {}\n File.open(@c.graph,\"r\").each do |l|\n parts = l.split(' ',3)\n id1,id2 = parts[0].to_i, parts[1].to_i\n degrees[id2] ||= [0,0]\n degrees[id1] ||= [0,0]\n degrees[id2][0] += 1\n degrees[id1][1] += 1\n #id1,id2 = id2,id1 if id2 < id1\n edges[id1] ||= Set.new\n edges[id1].add id2\n end\n \n # Write in-degree count to file\n puts \"Writing in/out-degree to file...\"\n File.open(@c.degrees+\"~\", \"w\") do |f|\n degrees.each do |k,v|\n f.puts \"#{k} #{v[0]} #{v[1]}\"\n end\n end\n File.rename(@c.degrees+\"~\", @c.degrees)\n \n # Count in-degrees & loop through edges and count and write to file\n puts \"Writing directed edges to file...\"\n File.open(@people_edge_filename+\"~\", \"w\") do |f|\n edges.each do |k,v|\n v.each do |k2|\n f.puts \"#{k} #{k2}\"\n # degrees[k] ||= 0\n # degrees[k2] ||= 0\n # degrees[k] += 1\n # degrees[k2] += 1\n end\n end\n end\n File.rename(@people_edge_filename+\"~\", @people_edge_filename)\n \n end",
"def in_celsius\n\t\tif(@unit.to_s == \"c\")\n\t\t\t@degree\n\t\telse\n\t\t\t(@degree - 32) * (5.0/9.0)\n\t\tend\n\tend",
"def in_fahrenheit\n\t\tif(@unit.to_s == \"f\")\n\t\t\t@degree\n\t\telse\n\t\t\t(@degree * (9.0/5.0)) + 32\n\t\tend\n\tend",
"def test_no_correcto\n\t\tassert_equal(10, @circle.rad(75.36) )\n\tend",
"def authenticated?()\n\n odd_degree_count = 0;\n\n for i in 0..@number_of_vertices-1 do\n if @adjacent_list[i].length != @indegree[i]\n odd_degree_count += 1\n end\n end\n\n return false if(odd_degree_count!= 0 && odd_degree_count!= 2)\n\n (odd_degree_count == 0 && self.is_eulerian_circuit?) || (odd_degree_count ==2 && self.is_eulerian_path?)\n end",
"def test_messages_per_degree_in\n msgs = {1 => 10.0, 2 => 13.0, 3 => 15.0}\n degs = {1 => 2.0, 2 => 1.0, 3 => 3.0 }\n msgedges = { [1,2] => 5.0, [2,3] => 6.0, [1,3] => 7.0 }\n r = ReciprocityHeuristics::MessagesPerDegreeDecision.new(@c, msgs, degs, msgedges, :in)\n assert_equal(0.0,r.result(1,2,:rec))\n assert_equal(0.4,r.result(1,3,:rec))\n assert_equal(0.8,r.result(1,3,:unr))\n assert_equal(1.0,r.result_directed(1,3,:unr))\n assert_equal(2.0,r.result_directed(1,3,:rec))\n assert_equal(8.0/15,r.result_directed(3,1,:unr))\n assert_equal(0.8,r.result_directed(3,1,:rec))\n assert_equal(5.0,r.result_directed_onesided(1,3,:unr))\n assert_equal(5.0,r.result_directed_onesided(1,3,:rec))\n assert_equal(5.0,r.result_directed_v(1,3,:unr))\n assert_equal(10.0,r.result_directed_v(1,3,:rec))\n end",
"def out_degree(node)\n @structure.count { |_source, dest| dest.include? node }\n end",
"def out_degree(node)\n @adj[node].length\n end",
"def degree(x, direction = :all)\n r = Hash.new(0)\n vertexes.each do |i|\n r[:in] += 1 if connected?(i, x)\n r[:out] += 1 if connected?(x, i)\n end\n r[:all] = r[:in] + r[:out]\n r[direction]\n end",
"def test_008_phase\n assert_equal 'edge', @me.phase\n end",
"def degree(x, direction = :all)\n r = Hash.new(0)\n (0..@store.size).each do |i|\n r[:in] += 1 if connected?(i, x)\n r[:out] += 1 if connected?(x, i)\n end\n r[:all] = r[:in] + r[:out]\n return r[direction] / 2 if undirected?\n r[direction]\n end",
"def equals(aTemp)\n temp1 = self.getInF()\n temp2 = aTemp.getInF()\n return temp1.myDegree == temp2.myDegree\n end",
"def alienlang(graph, in_degrees)\n g, deg, visited, solution = graph, in_degrees, 0, []\n\n # enqueue all vertices with an in-degree of 0\n queue = []\n deg.each do |k, v|\n if v == 0\n queue << k\n deg.delete(k)\n end\n end\n\n # until que is empty\n until queue.empty?\n solution << queue.shift\n visited += 1\n\n # traverse graph and remove edges\n parent = solution.last\n child = g[parent]\n # update in-degree count\n if deg.include?(child)\n deg[child] -= 1\n if deg[child] == 0 \n queue << child\n deg.delete(child)\n end\n end\n end\n\n g.length == visited ? solution : \"\"\nend",
"def at degree\n raise \"Degree must be 1 or greater... there is no degree 0!\" if degree.to_i == 0\n if degree.respond_to? :match\n accidental = degree.match(/b/) ? -1 : 0\n accidental = degree.match(/#/) ? 1 : accidental\n else\n accidental = 0\n end\n index = degree.to_i - 1\n octave = index / @intervals.size\n @intervals[(index % @intervals.size)] + (octave * 12) + @tonic + accidental\n end",
"def degree_params\n params[:degree]\n end",
"def out_degree(source)\n h = @pathway.graph[source]\n h ? h.size : 0\n end",
"def test_start_angle_on_circle\n start_angle = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 11\n edge = edgearray[0]\n arccurve = edge.curve\n start_angle = arccurve.start_angle\n end\n assert_equal(0.0, start_angle,\n 'Failed: start_angle != PI*2' )\n end",
"def test_check_coins_true\r\n assert_equal 1, @g.check_coins('1')\r\n end",
"def out_degree\n @out_edges.length\n end",
"def test_fish_in_river()\n assert_equal(0, @river.fish_in_river())\n end",
"def n_indegree(node, counts=false, k=2)\n n_inoutdegree(node, @destlinks, counts, k)\n end",
"def perfect_degrees degree\n # remember: a fourth from degree is (degree + 3)\n candidates = [degree - 4, degree - 3, degree + 3, degree + 4].reject{|d| d < 1}\n perfect = candidates.select{ |cd| [-7, -5, 5, 7].include?(at(cd) - at(degree)) }\n perfect << degree + 7 << degree - 7\n perfect.reject{|d| d < 1}\n end",
"def degrees\n Enumerator.new(@structure.length) do |y|\n nodes.each do |node|\n y << [node, degree(node)]\n end\n end\n end",
"def degrees\n\t\t@degrees ||= cardinal.keys.sort + [360.0]\n\tend",
"def set_degree\n @degree = Degree.find(params[:id])\n end",
"def set_degree\n @degree = Degree.find(params[:id])\n end",
"def test_annuity_credit_results\n @annuity_credit_Value.each { |key, value| assert_in_delta @calc_annuity[@row_number][key], value, 0.03 }\n check_count @calc_annuity\n end",
"def eulerian_path(graph)\n # We can just use the eulerian cycle problem by just choosing the \n # first node which has greater outdegree than indegree\n\n node = graph.keys[0]\n in_degrees = {}\n graph.values.flatten.each do |val|\n in_degrees[val] = 0 unless in_degrees.has_key?(val)\n in_degrees[val] += 1\n end\n # puts in_degrees.to_s\n graph.each do |k,v|\n if in_degrees.has_key?(k) and v.length > in_degrees[k]\n node = k\n break\n end\n unless in_degrees.has_key?(k)\n node = k\n break\n end\n end\n stack = [node]\n cycle = []\n while (not stack.empty?)\n node = stack[-1]\n if graph.has_key?(node)\n new_node = graph[node][0]\n # puts \"New node:\" + new_node\n stack << new_node\n if graph[node].length > 1\n graph[node].delete(new_node)\n else\n graph.delete(node)\n end\n else\n cycle.unshift(stack.pop)\n # puts stack.join(\" \")\n end\n end\n\n return cycle \n end",
"def test_start_angle_negative_stays_negative\n start_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,40\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = -Math::PI/2\n end_a = Math::PI\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n start_angle = arccurve.start_angle\n end\n assert_equal(-Math::PI/2, start_angle,\n 'Failed: start_angle != -Math::PI/2' )\n end",
"def test_start_angle_large_angle\n start_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.5\n end_a = 3.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n start_angle = arccurve.start_angle\n end\n assert_equal(0.5, start_angle,\n 'Failed: start_angle != 0.0' )\n end",
"def test_end_angle_on_circle\n end_angle = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 11\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(Math::PI*2, end_angle,\n 'Failed: end_angle != PI*2' )\n end",
"def test_distance_to_one_deg\n start = { latitude: 0.0, longitude: 0.0 }\n finish = { latitude: 0.0, longitude: 1.0 }\n\n distance = Vincenty.distance_between_points(start, finish)\n\n assert_in_delta 111_319.491, distance, 0.001\n end",
"def root?(node)\n in_degree(node) == 0 && out_degree(node) > 0\n end",
"def test_perfind_evidence\r\n nodelist = @mymodel.node_list\r\n \r\n node1 = nodelist.add_node(1, 'node one', PERFIND);\r\n \r\n assert_equal(Evidence.undefined, node1.measure_to_evidence(nil))\r\n\r\n node1.value_function = ValueFunction.new(0, 100, 'degrees')\r\n\r\n assert_equal(Evidence.undefined, node1.measure_to_evidence(nil)) \r\n assert_in_delta(node1.measure_to_evidence(45.4), 0.454, 0.0001)\r\n end",
"def degree node\n d = 0\n if (@connections[node].is_a? (Array)) && nodes.include?(node)\n d = @connections[node].count\n if @connections[node].include?(node)\n d += 1\n end\n end\n return d\n end",
"def retrograde?\n inclination_rad > PI / 2\n end",
"def test_check_in\n assert_equal(true, @room1.check_in(@guest1))\n end",
"def set_degree\n @degree = Degree.find(params[:id])\n end",
"def angle_deg\n angle * RAD_TO_DEG\n end",
"def degrees\n self\n end",
"def test_promedio_edades\n n=5\n print validate(23.2, promedio_edades(n)) \nend",
"def test_get_number_passengers\n assert_equal(0, @bus1.number_passengers())\n end",
"def test_halfway_arround_sum_1212\n assert_equal 6, subject(1212).halfway_around_sum\n end",
"def passed?\n @grade >= 2.0\n end",
"def obtuse?\n angles.map(&:degrees).max > 90.0\n end",
"def test_check_player_in__true\n result = @team.check_player_in(\"Valentina\")\n assert_equal(true,result)\n end",
"def calc_inches_per_degree(radius)\r\n if (radius == 0)\r\n return 0\r\n else\r\n return calc_circumference(radius) / 360.0\r\n end\r\nend",
"def test_exercise_115\n verify_method :exercise_115,\n :with => [{param: [0.8, 0.8], expect: true},\n {param: [0.1, 0.1], expect: true},\n {param: [0.9, 0.9], expect: true},\n {param: [1, 1], expect: false},\n {param: [0, 0], expect: false}]\n end",
"def test_initiative_in_range\n assert_in_delta(@fighter.initiative, 4.5, 4.6)\n end",
"def in?(*p)\n point = p.to_point\n point.in?(self.computed)\n end",
"def test_01b_number_of_days_in_a_normal_nonleap_year \n cal = IndividualMonth.new(2013, 2)\n assert_equal(28, cal.number_days_in_a_month)\n end",
"def inverseDeg(point)\r\n inverseDeg!(point.dup)\r\n end",
"def test_diners\n \n assert_equal(@check_test.diners, @check_test.diners.to_i)\n end",
"def test_verified_by_fai_distance\n start = { latitude: 44.34980359273743, longitude: 12.17773479543761 }\n finish = { latitude: 44.35679018739903, longitude: 12.21939248804523 }\n\n distance = Vincenty.distance_between_points(start, finish)\n\n assert_in_delta 3410.841, distance, 0.001\n end",
"def jump(end_degree, start_degree = 0)\n (start_degree...end_degree).sum do |i|\n intervals[i]\n end\n end",
"def traverse_graph\n for i in 0..@number_of_vertices-1 do\n if @adjacent_list[i].length > 0 && @adjacent_list[i].length > @indegree[i]\n break\n end\n end\n\n return true if (i == @number_of_vertices)\n\n dfs_traversal(i);\n\n for i in 0..@number_of_vertices-1\n if (@visited[i] == false && @adjacent_list[i].length > 0)\n return false\n end\n end\n end",
"def initialize(degree: 2)\n raise ArgumentError, 'Expect the value of degree parameter greater than or eqaul to 1.' if degree < 1\n\n super()\n @params = { degree: degree }\n end",
"def test_in_edges_on_examples\n assert_equal(@small_dfa.ith_edges(4), @small_dfa.in_edges(0,true))\n assert_equal(@small_dfa.ith_edges(0,5), @small_dfa.in_edges(1,true))\n assert_equal(@small_dfa.ith_edges(1,3), @small_dfa.in_edges(2,true))\n assert_equal(@small_dfa.ith_edges(2), @small_dfa.in_edges(3,true))\n\n assert_equal(@small_nfa.ith_edges(5), @small_nfa.in_edges(0,true))\n assert_equal(@small_nfa.ith_edges(0,1,6), @small_nfa.in_edges(1,true))\n assert_equal(@small_nfa.ith_edges(2), @small_nfa.in_edges(2,true))\n assert_equal(@small_nfa.ith_edges(3,4), @small_nfa.in_edges(3,true))\n end",
"def deg_vertex v\n\n\t\tdeg=0\n\n\t\t# Store vertex v as temp variable\n\t\ttmp = v\n\n\t\t# For all Edges, check their points to see if v.label is in them. If it is, increment\n\t\tfor i in 0..@Edges.length-1\n\t\t\tif @Edges[i].points[0] == v.label\n\t\t\t\tdeg+=1\n\t\t\tend\n\t\t\tif @Edges[i].points[1] == v.label\n\t\t\t\tdeg+=1\n\t\t\tend\n\t\tend\n\n\t\t# Return number of degrees\n\t\treturn deg\n\tend",
"def test_check_coins_alpah\r\n assert_nil @g.check_coins('a')\r\n end",
"def angenehm?(in_temp)\n\tcheck_pre((in_temp.int?))\n#\tANGENEHM_RANGE === in_temp\n in_temp.in?(ANGENEHM_RANGE)\nend",
"def is_in(&block)\n [:is_in, block]\n end",
"def is_in(&block)\n [:is_in, block]\n end",
"def n_degree(node, counts=false, k=2)\n d = n_indegree(node,counts,k) + n_outdegree(node,counts,k)\n if l=@links[[node,node]]\n # to be repaired!\n case counts\n when true, :add\n d -= l.weight\n when false, nil, :nodes\n d -= 1\n else\n raise \"fixme: no self links for these degrees allowed currently\"\n end\n end\n d\n end",
"def test_life_algorithm\n assert_equal 0,@game.next_life_state(0,0)\n assert_equal 0,@game.next_life_state(1,0)\n assert_equal 0,@game.next_life_state(2,0)\n\n assert_equal 0,@game.next_life_state(0,2)\n assert_equal 1,@game.next_life_state(1,2)\n assert_equal 0,@game.next_life_state(2,2)\n\n assert_equal 1,@game.next_life_state(0,3)\n assert_equal 1,@game.next_life_state(1,3)\n assert_equal 0,@game.next_life_state(2,3)\n\n assert_equal 0,@game.next_life_state(0,4)\n assert_equal 0,@game.next_life_state(1,4)\n assert_equal 0,@game.next_life_state(2,4)\n end",
"def degrees\n self * Math::PI / 180\n end",
"def test_waistlisted_nonmember\n\t\tnon_member = enrollments(:non_member_two)\n\t\texpected = 1\n\t\tassert_equal expected, non_member.waitlist_status, \"Supposedly waitlisted non member is not waitlisted\"\n\tend",
"def degrees\n self * Math::PI / 180.0\n end",
"def test_returns_strength_value_halved\n skip\n end",
"def test_cayman_islands\n end",
"def test_under_age\n\t\tassert_equal true, @user.age(14)\n\tend",
"def check_fitness\r\n\t\tcourse = Course.find_by(courseID: courseID)\r\n\t\treturn course.intensity > 0\r\n\tend",
"def test_end_angle_negative_stays_negative\n end_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,40\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.0\n end_a = -Math::PI\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(-Math::PI, end_angle,\n 'Failed: end_angle != -PI' )\n end",
"def test_perimeter_method\n r = Rectangle.new(5, 15)\n\n assert_equal(40, r.perimeter)\n end",
"def deg _args\n \"deg _args;\" \n end",
"def test_get_dino\n\t\t@new_driver.dino 5\n\t\tassert_equal 5, @new_driver.dino(0)\n\tend",
"def test_check_in__fail\n assert_equal(false, @room2.check_in(@guest1))\n end",
"def test_01d_number_of_days_in_a_weird_leap_year\n cal = IndividualMonth.new(2100, 2)\n assert_equal(28, cal.number_days_in_a_month)\n end"
] |
[
"0.7368912",
"0.6845612",
"0.6654296",
"0.6463978",
"0.63506055",
"0.61380655",
"0.6129609",
"0.6096297",
"0.609111",
"0.6089261",
"0.60667974",
"0.59744346",
"0.59245294",
"0.58623236",
"0.58312917",
"0.58229214",
"0.58207643",
"0.57796717",
"0.5744778",
"0.56702095",
"0.5640933",
"0.5579249",
"0.55368793",
"0.5529804",
"0.55130094",
"0.5435475",
"0.54121023",
"0.5406243",
"0.5395448",
"0.53463614",
"0.5307055",
"0.52511877",
"0.52441114",
"0.52327776",
"0.5164557",
"0.51244634",
"0.5123077",
"0.5117379",
"0.5112576",
"0.5082169",
"0.50598884",
"0.50450337",
"0.50366056",
"0.5028265",
"0.4972883",
"0.4961461",
"0.49417862",
"0.49417862",
"0.4939546",
"0.4930471",
"0.4927565",
"0.492292",
"0.49212906",
"0.4914794",
"0.49068812",
"0.4905336",
"0.4902862",
"0.4884758",
"0.48788863",
"0.4876952",
"0.48762962",
"0.48632622",
"0.4851926",
"0.4826364",
"0.48217446",
"0.48133832",
"0.48113096",
"0.4811119",
"0.48099393",
"0.47947472",
"0.47826162",
"0.47760192",
"0.47568035",
"0.47461364",
"0.47448826",
"0.47415364",
"0.47369",
"0.4725425",
"0.47239405",
"0.47238168",
"0.4721921",
"0.47211763",
"0.47113797",
"0.47105682",
"0.47105682",
"0.4707095",
"0.4698113",
"0.46941796",
"0.46940827",
"0.4681113",
"0.4675067",
"0.46725485",
"0.4668323",
"0.46682528",
"0.46668902",
"0.4652354",
"0.46464944",
"0.46408352",
"0.4636457",
"0.46360978"
] |
0.7744613
|
0
|
Test the out_degree method.
|
def test_out_degree
setup_test_tree
assert_equal(3, @root.out_degree, "Root's out-degree should be 3")
assert_equal(0, @child1.out_degree, "Child 1's out-degree should be 0")
assert_equal(0, @child2.out_degree, "Child 2's out-degree should be 0")
assert_equal(1, @child3.out_degree, "Child 3's out-degree should be 1")
assert_equal(0, @child4.out_degree, "Child 4's out-degree should be 0")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def degree\n self.in_degree + self.out_degree\n end",
"def out_degree(vertex)\n\tend",
"def out_degree\n @out_edges.length\n end",
"def out_degree(v)\n r = 0\n each_adjacent(v) { |u| r += 1 }\n r\n end",
"def out_degree(node)\n @adj[node].length\n end",
"def out_degree(node)\n @structure.count { |_source, dest| dest.include? node }\n end",
"def n_outdegree(node, counts=false, k=2)\n n_inoutdegree(node, @sourcelinks, counts, k)\n end",
"def outDegree( name )\n\tif vertex?( name )\n\t\treturn @vertices[ name ].size\n\tend\n\treturn 0\n end",
"def out_degree(source)\n h = @pathway.graph[source]\n h ? h.size : 0\n end",
"def degree(v) in_degree(v); end",
"def outDegree( name )\n if (@vertices.has_key? name)\n\t\treturn @vertices[name].size\n\telse\n\t\treturn 0\n\tend\n end",
"def test_in_degree\n setup_test_tree\n\n assert_equal(0, @root.in_degree, \"Root's in-degree should be zero\")\n assert_equal(1, @child1.in_degree, \"Child 1's in-degree should be 1\")\n assert_equal(1, @child2.in_degree, \"Child 2's in-degree should be 1\")\n assert_equal(1, @child3.in_degree, \"Child 3's in-degree should be 1\")\n assert_equal(1, @child4.in_degree, \"Child 4's in-degree should be 1\")\n end",
"def degree(node)\n in_degree(node) + out_degree(node)\n end",
"def degree; end",
"def find_degrees_edges\n raise RuntimeError, \"Call filter_graph_by_users before find_degrees\" unless File.exist? @graph_filename\n \n # Open graph file and read in undirected edges\n puts \"Reading in edges from graph & calculating in/outdegree...\"\n edges = {}\n degrees = {}\n File.open(@c.graph,\"r\").each do |l|\n parts = l.split(' ',3)\n id1,id2 = parts[0].to_i, parts[1].to_i\n degrees[id2] ||= [0,0]\n degrees[id1] ||= [0,0]\n degrees[id2][0] += 1\n degrees[id1][1] += 1\n #id1,id2 = id2,id1 if id2 < id1\n edges[id1] ||= Set.new\n edges[id1].add id2\n end\n \n # Write in-degree count to file\n puts \"Writing in/out-degree to file...\"\n File.open(@c.degrees+\"~\", \"w\") do |f|\n degrees.each do |k,v|\n f.puts \"#{k} #{v[0]} #{v[1]}\"\n end\n end\n File.rename(@c.degrees+\"~\", @c.degrees)\n \n # Count in-degrees & loop through edges and count and write to file\n puts \"Writing directed edges to file...\"\n File.open(@people_edge_filename+\"~\", \"w\") do |f|\n edges.each do |k,v|\n v.each do |k2|\n f.puts \"#{k} #{k2}\"\n # degrees[k] ||= 0\n # degrees[k2] ||= 0\n # degrees[k] += 1\n # degrees[k2] += 1\n end\n end\n end\n File.rename(@people_edge_filename+\"~\", @people_edge_filename)\n \n end",
"def test_out_edges_on_examples\n assert_equal(@small_dfa.ith_edges(0), @small_dfa.out_edges(0,true))\n assert_equal(@small_dfa.ith_edges(1,2,5), @small_dfa.out_edges(1,true))\n assert_equal(@small_dfa.ith_edges(4), @small_dfa.out_edges(2,true))\n assert_equal(@small_dfa.ith_edges(3), @small_dfa.out_edges(3,true))\n\n assert_equal(@small_nfa.ith_edges(0), @small_nfa.out_edges(0,true))\n assert_equal(@small_nfa.ith_edges(1,2,3), @small_nfa.out_edges(1,true))\n assert_equal(@small_nfa.ith_edges(4,6), @small_nfa.out_edges(2,true))\n assert_equal(@small_nfa.ith_edges(5), @small_nfa.out_edges(3,true))\n end",
"def test_007_check_out_of_room\n @guest1.check_out(@occupied_room)\n assert_equal(0,@occupied_room.get_tab)\n assert_equal(10,@occupied_room.get_earnings)\n refute(@occupied_room.room_status)\n end",
"def in_degree(vertex)\n\tend",
"def degree(v)\n in_degree(v) + out_degree(v)\n end",
"def in_degree(node)\n @pred[node].length\n end",
"def get_out_degree(url, topic)\n\tout_degree_url = \"#{url}/wiki/Special:WhatLinksHere/#{topic}?limit=5000\"\n\tout_degree_string=\"\"\n\topen(out_degree_url) { |data| \n\t\tout_degree_string = data.read\n\t}\n\n\tlist_regex = /<ul id=\"mw-whatlinkshere-list\">.*?<\\/ul>View/m\n\tout_degree_string = list_regex.match(out_degree_string).to_s\n\tout_links = filter_links(out_degree_string)\n\treturn out_links.length\nend",
"def imperfect_degrees degree\n # remember: a third from degree is (degree + 2)\n candidates = [degree - 5, degree - 2, degree + 2, degree + 5].reject{|d| d < 1}\n imperfect = candidates.select{ |cd| [-9, -8, -4, -3, 3, 4, 8, 9].include?(at(cd) - at(degree))}\n end",
"def in_degree\n @in_edges.length\n end",
"def test_check_out__fail\n assert_equal(false, @room1.check_out(@guest2))\n end",
"def check_out\n @policy.check?\n note = operation_params[:note]\n operation = current_user.register_out(@employee, note)\n operation ? success(operation) : unprocessable_entity(operation)\n end",
"def in_degree(node)\n self[node].length\n end",
"def offer_degree?\n institution_of_higher_learning_indicator || non_college_degree_indicator\n end",
"def test_check_group_out_of_room()\n @room.check_in(@group2)\n @room.check_out()\n assert_equal(0, @room.karaoke_room_occupied())\n end",
"def n_indegree(node, counts=false, k=2)\n n_inoutdegree(node, @destlinks, counts, k)\n end",
"def in_degree(v)\n r = 0\n each_in_neighbor(v) { |u| r += 1 }\n r\n end",
"def test_returns_strength_value_halved\n skip\n end",
"def test_end_angle_negative_stays_negative\n end_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,40\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.0\n end_a = -Math::PI\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(-Math::PI, end_angle,\n 'Failed: end_angle != -PI' )\n end",
"def test_008_phase\n assert_equal 'edge', @me.phase\n end",
"def touch_out\n deduct(CHARGE)\n @in_journey = false\n end",
"def test_check_out\n @double_room.check_in(@guest2)\n assert_equal(@guest2, @double_room.current_guest)\n end",
"def n_degree(node, counts=false, k=2)\n d = n_indegree(node,counts,k) + n_outdegree(node,counts,k)\n if l=@links[[node,node]]\n # to be repaired!\n case counts\n when true, :add\n d -= l.weight\n when false, nil, :nodes\n d -= 1\n else\n raise \"fixme: no self links for these degrees allowed currently\"\n end\n end\n d\n end",
"def omit_degree_2_nodes\r\n # add all nodes into a queue\r\n # queue = put all nodes from @nodes into the queue\r\n # puts \"#{@vertices}\"\r\n queue = Queue.new\r\n @vertices.each do |node|\r\n queue << node\r\n end\r\n\r\n # iterate through all nodes until queue is not empty\r\n while ! queue.empty?\r\n # take the first node number from the queue\r\n # i = queue.deque()\r\n # take the first node itself\r\n node=queue.pop\r\n\r\n # puts \"osm_id=#{node.osm_id} degree=#{node.degree}\"\r\n # puts \"node neighbours #{node.neighbours}\"\r\n # do anything only iff this node's degree == 2\r\n if node.degree == 2\r\n # take the node's neighbours and the two edges going from the node\r\n # we would like to shrink these two edges into only one while isolating\r\n # the _node_\r\n v1_nr = node.neighbours[0]\r\n e1_nr = node.edges[0]\r\n v2_nr = node.neighbours[1]\r\n e2_nr = node.edges[1]\r\n\r\n #puts \"actual node: #{node.osm_id} , actual neighbours #{v1_nr} , #{v1_nr}\"\r\n #puts \"neigbours of #{node.osm_id}: #{v1_nr.osm_id} #{v2_nr.osm_id}\" if (node.neighbours.length==2)\r\n next if node.neighbours.length!=2\r\n\r\n # IMPORTANT!\r\n # however, if there was a cycle, which means that the node's neighbours\r\n # ARE already connected, do nothing and leave this degree-2-node _i_ as\r\n # it is!\r\n\r\n #puts \"are connected #{v1_nr}, #{v2_nr} of #{node.osm_id}?\"\r\n next if are_connected(v1_nr, v2_nr, node.osm_id)\r\n\r\n #puts \"handling #{node.osm_id} - has 2 and is not cyclic, going to delete neighbours!\"\r\n #puts \"cur_node is: #{node.osm_id}\"\r\n\r\n #puts \"# this is not needed, but just for sure: record the neighbours' degrees before the shrinkage\"\r\n #v1_deg = v1_nr.degree ; v2_deg = v2_nr.degree\r\n #puts \" -> neighbours degree: v1:#{v1_deg} v2:#{v2_deg}\"\r\n\r\n #puts \"# record the neighbours' OSM/id, for future use\"\r\n #v1_osm = v1_nr.osm_id ; v2_osm = v2_nr.osm_id\r\n #puts \" -> v1_osm: #{v1_osm} deg: #{v1_deg} :: v2_osm #{v2_osm} deg: #{v2_deg}\"\r\n\r\n #puts \"# invalidate the two edges -- particularly, do not output them into Graphviz output\"\r\n e1_nr.invalidate\r\n e2_nr.invalidate\r\n e_distance=e1_nr.time_distance+e2_nr.time_distance\r\n\r\n #puts \" -> invalidated edges - #{e1_nr} #{e1_nr.osm_from}-#{e1_nr.osm_to}(#{e1_nr.is_valid}) #{e2_nr} #{e2_nr.osm_from}-#{e2_nr.osm_to}(#{e2_nr.is_valid})\"\r\n #puts \"# disconnect the triple v1--i--v2, i.e. leave out the neighbours from\r\n # the nodes' own neighbours' lists\"\r\n #ns=[] ; v1_nr.neighbours.each do |n| ns << \"#{n.osm_id}\" end; puts \"old v1 neighbours : #{ns}\"\r\n #ns=[] ; v2_nr.neighbours.each do |n| ns << \"#{n.osm_id}\" end; puts \"old v2 neighbours : #{ns}\"\r\n #ns=[] ; node.neighbours.each do |n| ns << \"#{n.osm_id}\" end; puts \"old v neighbours : #{ns}\"\r\n\r\n node.disconnect_neighbour(v1_nr)\r\n node.disconnect_neighbour(v2_nr)\r\n v2_nr.disconnect_neighbour(node)\r\n v1_nr.disconnect_neighbour(node)\r\n node.invalidate\r\n\r\n #puts \"Disconnect edges from nodes\"\r\n #ns=[] ; v1_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \" -> old v1 neighbours : #{ns}\"\r\n #ns=[] ; v2_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \" -> old v2 neighbours : #{ns}\"\r\n v1_nr.disconnect_edge(e1_nr)\r\n v2_nr.disconnect_edge(e2_nr)\r\n\r\n #puts \" # create a new edge going from v1 into v2 (it does not matter in which direction, it is anyway an artificial/virtual edge\"\r\n # save this Edge into the array @edges\r\n v_nr = @vertices.length\r\n e = Edge.new(v1_nr.osm_id, v2_nr.osm_id, 0, v_nr, e1_nr.name, e1_nr.maxspeed, e1_nr.is_oneway, e_distance)\r\n\r\n #puts (\"new edge from #{v1_nr.osm_id} to #{v2_nr.osm_id}\")\r\n @edges.push(e)\r\n\r\n #puts \"#add edge to vertex\"\r\n #ns=[] ; v1_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \"old v1 edges : #{ns}\"\r\n #ns=[] ; v2_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \"old v2 edges : #{ns}\"\r\n v1_nr.add_edge(e)\r\n v2_nr.add_edge(e)\r\n\r\n #add linkeds to vetexes\r\n v1_nr.connect_neighbour(v2_nr)\r\n v2_nr.connect_neighbour(v1_nr)\r\n end\r\n end\r\n end",
"def is_finished(num, prerequisties) \n\t#edge is the desitnation, degree is the number of indegree\n\tedges = Array.new(num, Array.new(num, 0))\n\tdegrees = Array.new(num, 0)\n\n\t#update the edges and degrees base on the course number\n\tfor i in 0...prerequisties.length\n\t\tcrt_class = prerequisties[i][0]\n\t\tpre_class = prerequisties[i][1]\n\t\tdegrees[crt_class] += 1\n\t\tedges[pre_class].push(crt_class)\n\tend\n\n\t#fill the queue with courses with no prerequisties\n\tqueue = []\n\tfor i in 0...degrees.length \n\t\tif (degrees[i] == 0)\n\t\t\tqueue.push(i)\n\t\tend\n\tend\n\n\t#count number of times to make all indegrees to 0\n\tcount = 0\n\twhile (!queue.empty?)\n\t\tcourse = queue.delete_at(0)\n\t\tcount += 1\n\t\tn = edges[course].length\n\t\tfor i in 0...n\n\t\t\tpointer = edges[course][i]\n\t\t\tdegrees[pointer] -= 1\n\t\t\tif (degrees[pointer] == 0)\n\t\t\t\tqueue.push(pointer)\n\t\t\tend\n\t\tend\n\tend\n\t\n\treturn count == num\n\nend",
"def find_outlier(integers)\r\n\r\nend",
"def out_neighbors(vertex)\n\tend",
"def out_of_spec\n @out_of_spec ||= _out_of_spec\n end",
"def obtuse?\n angles.map(&:degrees).max > 90.0\n end",
"def inDegree( name )\n\tcount = 0\n if vertex?( name )\n\t\t@vertices.each_key{ |key| if edge?( key, name ) then count += 1 end}\n\tend\n\treturn count\n end",
"def test_messages_per_degree_in\n msgs = {1 => 10.0, 2 => 13.0, 3 => 15.0}\n degs = {1 => 2.0, 2 => 1.0, 3 => 3.0 }\n msgedges = { [1,2] => 5.0, [2,3] => 6.0, [1,3] => 7.0 }\n r = ReciprocityHeuristics::MessagesPerDegreeDecision.new(@c, msgs, degs, msgedges, :in)\n assert_equal(0.0,r.result(1,2,:rec))\n assert_equal(0.4,r.result(1,3,:rec))\n assert_equal(0.8,r.result(1,3,:unr))\n assert_equal(1.0,r.result_directed(1,3,:unr))\n assert_equal(2.0,r.result_directed(1,3,:rec))\n assert_equal(8.0/15,r.result_directed(3,1,:unr))\n assert_equal(0.8,r.result_directed(3,1,:rec))\n assert_equal(5.0,r.result_directed_onesided(1,3,:unr))\n assert_equal(5.0,r.result_directed_onesided(1,3,:rec))\n assert_equal(5.0,r.result_directed_v(1,3,:unr))\n assert_equal(10.0,r.result_directed_v(1,3,:rec))\n end",
"def inDegree( name )\n\t\n\tcount = 0\n if @vertices.has_key? name\n\t @vertices.each { |key,v| count+=1 if self.edge?(key,name) }\n\t end\n\treturn count\n end",
"def degrees(counts=false, k=2)\n h = Hash.new { |h,k| h[k] = [0,0,0] }\n @nodes.each { |n|\n h[n] = [n_outdegree(n,counts,k), n_indegree(n,counts,k), n_degree(n,counts,k)]\n }\n h\n end",
"def check_out\n @num_in -= 1\n @num_out += 1\n\n puts \"Inventory ERROR!!!!\" if @num_out > @num_copies\n end",
"def eulerian_path(graph)\n # We can just use the eulerian cycle problem by just choosing the \n # first node which has greater outdegree than indegree\n\n node = graph.keys[0]\n in_degrees = {}\n graph.values.flatten.each do |val|\n in_degrees[val] = 0 unless in_degrees.has_key?(val)\n in_degrees[val] += 1\n end\n # puts in_degrees.to_s\n graph.each do |k,v|\n if in_degrees.has_key?(k) and v.length > in_degrees[k]\n node = k\n break\n end\n unless in_degrees.has_key?(k)\n node = k\n break\n end\n end\n stack = [node]\n cycle = []\n while (not stack.empty?)\n node = stack[-1]\n if graph.has_key?(node)\n new_node = graph[node][0]\n # puts \"New node:\" + new_node\n stack << new_node\n if graph[node].length > 1\n graph[node].delete(new_node)\n else\n graph.delete(node)\n end\n else\n cycle.unshift(stack.pop)\n # puts stack.join(\" \")\n end\n end\n\n return cycle \n end",
"def get_in_degrees(graph)\n in_degrees = {}\n graph.keys.each { |vtx| in_degrees[vtx] = 0 }\n graph.values.each do |neighbors|\n neighbors.each do |neighbor|\n in_degrees[neighbor] += 1\n end\n end\n in_degrees\nend",
"def test_final_trans_false\n assert_equal(false, @bv.final_trans?([\"FROM_ADDR\", \"TO_ADDR\", \"46\"], 3, 4))\n end",
"def out\n score_point(other_player)\n return false\n end",
"def inverseDeg(point)\r\n inverseDeg!(point.dup)\r\n end",
"def test_final_trans_not_final_trans\n assert @bv.final_trans?([\"FROM_ADDR\", \"TO_ADDR\", \"46\"], 2, 4)\n end",
"def jump(end_degree, start_degree = 0)\n (start_degree...end_degree).sum do |i|\n intervals[i]\n end\n end",
"def test_payment_amount_for_output_with_sum_of_interest_and_payment\n eob = insurance_payment_eobs(:eob_57)\n facility = facilities(:facility_94)\n facility_output_config = facility_output_configs(:facility_config_226)\n total_payment_amount_for_output = eob.payment_amount_for_output(facility, facility_output_config)\n assert_equal(total_payment_amount_for_output, 48.00)\n end",
"def find_outlier(array)\n even_parity? = true",
"def test_no_correcto\n\t\tassert_equal(10, @circle.rad(75.36) )\n\tend",
"def test_backward_node\n loss = DNN::Losses::MeanSquaredError.new\n y = Numo::SFloat[[0, 1]]\n t = Numo::SFloat[[2, 4]]\n loss.forward_node(y, t)\n grad = loss.backward_node(Numo::SFloat[1])\n assert_equal Numo::SFloat[[-2, -3]], grad.round(4)\n end",
"def test_end_angle_on_circle\n end_angle = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 11\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(Math::PI*2, end_angle,\n 'Failed: end_angle != PI*2' )\n end",
"def root?(node)\n in_degree(node) == 0 && out_degree(node) > 0\n end",
"def test_out_adjacent_states_on_examples\n assert_equal(@small_dfa.ith_states(1), @small_dfa.out_adjacent_states(0).sort)\n assert_equal(@small_dfa.ith_states(1,2,3), @small_dfa.out_adjacent_states(1).sort)\n assert_equal(@small_dfa.ith_states(0), @small_dfa.out_adjacent_states(2).sort)\n assert_equal(@small_dfa.ith_states(2), @small_dfa.out_adjacent_states(3).sort)\n\n assert_equal(@small_nfa.ith_states(1), @small_nfa.out_adjacent_states(0).sort)\n assert_equal(@small_nfa.ith_states(1,2,3), @small_nfa.out_adjacent_states(1).sort)\n assert_equal(@small_nfa.ith_states(1,3), @small_nfa.out_adjacent_states(2).sort)\n assert_equal(@small_nfa.ith_states(0), @small_nfa.out_adjacent_states(3).sort)\n end",
"def meridian_convergence_deg(from, to)\n return 0.0 if distance_nm(from, to) < 0.001\n true_tk_outbound(from, to) - true_tk_inbound(from, to)\n end",
"def test_end_angle_large_angle\n end_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.0\n end_a = 3.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(Math::PI*2, end_angle,\n 'Failed: end_angle != PI*2' )\n end",
"def test_halfway_arround_sum_1212\n assert_equal 6, subject(1212).halfway_around_sum\n end",
"def outside?\r\n return @name.scan(/\\[OUT\\]/).size > 0\r\n end",
"def handleConjured\n handleStandardDegredation(2)\n end",
"def == expected\n self.out == expected\n end",
"def verify_out_file\n header_hash = get_header\n verify_file(:OUT, header_hash)\n end",
"def test_19_createofflinedonations_verifythermometer()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 19 ----------------------\"\n\t\tcreateOfflineDonation($offline_donorname, $offline_donoremail, $offline_donoramount)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 19 ----------------------\"\n\t\n\tend",
"def test_correcto\n\t\tassert_equal(12, @circle.rad(75.36) )\n\tend",
"def degree(vertex)\n\tend",
"def test_guests_checked_out_of_room\n @room1.guest_check_in(@guest1)\n @room1.guest_check_in(@guest2)\n @room1.guest_check_out(@guest2)\n assert_equal(1, @room1.guests_number())\n end",
"def test_leaving_last_2_false_gold_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 2\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\trefute p.leaving?\n end",
"def find_way_out\n\t\t#Step 1: Put the pawn on the start_pos.\n\t\t@pawn.current_pos = @start_pos\n\n\t\t# Step 2: The pawn should check if it can go right, left, up, down.\n\t\t# If it can, it should go in the first direction it can.\n\t\t# If it can't, then the maze can't be solved.\n\t\tuntil @game_over\n\t\t\tmake_a_move\n\t\t\t@maze.place_pawn(@pawn.current_pos, @pawn.name)\n\n\t\t# Step 3: After every move we need to check if the pawn is at the E.\n\t\t\t@game_over = true if reached_end?\n\t\tend\n\tend",
"def test_check_out_guest()\n @room_1.check_in_guest(@guest_1) #add 1 guest\n @room_1.check_in_guest(@guest_2) # add 2nd guest to total 2\n @room_1.check_out_guest(@guest_1) #remove one guest to total 1\n assert_equal(1, @room_1.check_in_count()) #output shoudl be 1\n @room_1.check_out_guest(@guest_3) #checkout guest 3 who is not checked in so should still return 1\n assert_equal(1, @room_1.check_in_count()) #returns 1\n @room_1.check_out_guest(@guest_2) #check out guest 2 who is checked in\n assert_equal(0, @room_1.check_in_count()) #room should now be empty\n end",
"def assert_no_outage_loss(num_passed_outages, srcdst2filter_tracker)\n num_passed_trackers = srcdst2filter_tracker.find_all { |srcdst, filter_tracker| filter_tracker.passed? }.size\n if num_passed_outages != num_passed_trackers\n @logger.warn { \"# of passed outages (#{num_passed_outages}) != # of passed filters (#{num_passed_trackers}) #{caller[0..3]}\" }\n end\n end",
"def electricity_losses_if_export_is_zero\n transformer_demand = graph.node(:energy_power_transformer_mv_hv_electricity).demand\n own_use_of_sector = energy_sector_own_use_electricity\n node = graph.node(:energy_power_hv_network_electricity)\n conversion_loss = node.output(:loss).conversion\n conversion_electricity = node.output(:electricity).conversion\n\n return 0.0 if conversion_electricity.zero?\n\n (transformer_demand + own_use_of_sector) * conversion_loss / conversion_electricity\n end",
"def determinant\n end",
"def test_leaving_last_2_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 1\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\tassert p.leaving?\n end",
"def io_out_corr?(in_element)\n @io_corr.out_corr?(in_element)\n end",
"def degree(x, direction = :all)\n r = Hash.new(0)\n (0..@store.size).each do |i|\n r[:in] += 1 if connected?(i, x)\n r[:out] += 1 if connected?(x, i)\n end\n r[:all] = r[:in] + r[:out]\n return r[direction] / 2 if undirected?\n r[direction]\n end",
"def right?\n angles.map(&:degrees).include? 90.0\n end",
"def test_get_number_passengers\n assert_equal(0, @bus1.number_passengers())\n end",
"def test_cash_out\n p = Prospector.new(0,0,0)\n\tp.total_gold = 1\n\tp.total_silver = 1\n\tassert '21.98', p.cash_out\n end",
"def retrograde?\n inclination_rad > PI / 2\n end",
"def perfect_degrees degree\n # remember: a fourth from degree is (degree + 3)\n candidates = [degree - 4, degree - 3, degree + 3, degree + 4].reject{|d| d < 1}\n perfect = candidates.select{ |cd| [-7, -5, 5, 7].include?(at(cd) - at(degree)) }\n perfect << degree + 7 << degree - 7\n perfect.reject{|d| d < 1}\n end",
"def authenticated?()\n\n odd_degree_count = 0;\n\n for i in 0..@number_of_vertices-1 do\n if @adjacent_list[i].length != @indegree[i]\n odd_degree_count += 1\n end\n end\n\n return false if(odd_degree_count!= 0 && odd_degree_count!= 2)\n\n (odd_degree_count == 0 && self.is_eulerian_circuit?) || (odd_degree_count ==2 && self.is_eulerian_path?)\n end",
"def verify_answer(answer)\n if answer == @total.to_s\n puts \"Right!\".green\n @current_player.get_point\n else\n puts \"Wrong! The correct answer is #{@total}.\".red\n @current_player.lose_life\n end\n end",
"def almost_at_angle(target_angle, current_angle, error)\n\t\t(target_angle - current_angle).abs <= error\n\tend",
"def test_out_of_bounds\n assert_raise Proj4::LatitudeOrLongitudeExceededLimitsError do\n @proj_gk.forward( Proj4::Point.new( deg2rad(190), deg2rad(92) ) ) \n end\n end",
"def user_takeout\n\n check_for_signed_in_user_and_issues\n\n @personal_roll_export = :true\n\n unless @user_signed_in\n @custom_error = \"Sorry, you must be signed in to export your data.\"\n else\n @display_export_form = :true\n end\n\n render '/home/landing'\n end",
"def best_degree\n\t\terrors = []\n\n\t\t(2..10).to_a.each do |degree|\n\t\t\terrors[degree-2] = standard_error('polynomial', degree)\n\t\tend\n\n\t\terrors.index(errors.min) + 2 # Since indexes start with 0\n\tend",
"def hour_out\n @hour_out ||= time_out.hour\n end",
"def anti_parallel_edge(edge)\n edge.to.out_edges.to_a.detect { |o| o.to == edge.from }\n end",
"def outlier_member_type\n return @outlier_member_type\n end",
"def alienlang(graph, in_degrees)\n g, deg, visited, solution = graph, in_degrees, 0, []\n\n # enqueue all vertices with an in-degree of 0\n queue = []\n deg.each do |k, v|\n if v == 0\n queue << k\n deg.delete(k)\n end\n end\n\n # until que is empty\n until queue.empty?\n solution << queue.shift\n visited += 1\n\n # traverse graph and remove edges\n parent = solution.last\n child = g[parent]\n # update in-degree count\n if deg.include?(child)\n deg[child] -= 1\n if deg[child] == 0 \n queue << child\n deg.delete(child)\n end\n end\n end\n\n g.length == visited ? solution : \"\"\nend",
"def test_leaving_first_3_false_both_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 3\n\tp.silver_found = 4\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def upper( degrees)\r\n newDegrees = self.myDegrees + degrees\r\n checkIfValid(newDegrees, self.myScale)\r\n self.myDegrees = newDegrees\r\n end",
"def out_degree_of(name)\n if @words[name].nil? then\n Throw NoSuchWord\n else\n @words[name].size\n end\n end",
"def degree(x, direction = :all)\n r = Hash.new(0)\n vertexes.each do |i|\n r[:in] += 1 if connected?(i, x)\n r[:out] += 1 if connected?(x, i)\n end\n r[:all] = r[:in] + r[:out]\n r[direction]\n end"
] |
[
"0.6726331",
"0.67059845",
"0.6697559",
"0.65575594",
"0.653462",
"0.6340498",
"0.6224677",
"0.61898947",
"0.60682994",
"0.60337806",
"0.6027786",
"0.597832",
"0.5760423",
"0.5600363",
"0.5587584",
"0.5559842",
"0.5537469",
"0.54718786",
"0.54524803",
"0.5435376",
"0.5410193",
"0.5393208",
"0.52800936",
"0.52394044",
"0.5231182",
"0.5136868",
"0.51301515",
"0.5119715",
"0.51058817",
"0.506616",
"0.503766",
"0.49730623",
"0.49646258",
"0.49082726",
"0.49039903",
"0.4881093",
"0.48768413",
"0.48718455",
"0.4863972",
"0.48247153",
"0.48233834",
"0.4816429",
"0.481298",
"0.48113808",
"0.48089835",
"0.4797148",
"0.47921595",
"0.4792031",
"0.47900826",
"0.4785876",
"0.47503862",
"0.47391865",
"0.47361678",
"0.4727324",
"0.47269997",
"0.4721965",
"0.47202986",
"0.469187",
"0.46915737",
"0.4682871",
"0.46825057",
"0.46815032",
"0.46752086",
"0.466574",
"0.46549585",
"0.46478185",
"0.4641451",
"0.4635752",
"0.4624816",
"0.46218038",
"0.4616063",
"0.4615084",
"0.4611175",
"0.46049008",
"0.46044722",
"0.46019763",
"0.459758",
"0.458846",
"0.45815703",
"0.45772246",
"0.45765665",
"0.45700926",
"0.4550459",
"0.45499083",
"0.4547661",
"0.45395234",
"0.45368433",
"0.45353943",
"0.45218763",
"0.45213085",
"0.45129645",
"0.4507075",
"0.4492876",
"0.44869956",
"0.4482283",
"0.4482282",
"0.4481755",
"0.44766805",
"0.44748995",
"0.44725472"
] |
0.780635
|
0
|
Test the new JSON serialization method.
|
def test_json_serialization
setup_test_tree
expected_json = {
"name" => "ROOT",
"content" => "Root Node",
JSON.create_id => "Tree::TreeNode",
"children" => [
{"name" => "Child1", "content" => "Child Node 1", JSON.create_id => "Tree::TreeNode"},
{"name" => "Child2", "content" => "Child Node 2", JSON.create_id => "Tree::TreeNode"},
{
"name" => "Child3",
"content" => "Child Node 3",
JSON.create_id => "Tree::TreeNode",
"children" => [
{"name" => "Child4", "content" => "Grand Child 1", JSON.create_id => "Tree::TreeNode"}
]
}
]
}.to_json
assert_equal(expected_json, @root.to_json)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_serialization\n # TODO: test serialization methods\n end",
"def json_serialize\n end",
"def test_json_object_child\n obj = { 'child' => Jeez.new(true, 58) }\n assert_equal('{\"child\":{\"json_class\":\"CompatJuice::Jeez\",\"x\":true,\"y\":58}}', Oj.dump(obj))\n end",
"def serializer; end",
"def json?\n true\n end",
"def DISABLED_test_json\n require 'json'\n require 'json/pure'\n my_hash = JSON.parse('{\"hello\": \"goodbye\"}')\n JSON.generate(my_hash)\n end",
"def test_json_object_top\n obj = Jeez.new(true, 58)\n dump_to_json_and_load(obj, false)\n end",
"def serialize_in(json_string, options = {})\n super(ActiveSupport::JSON.decode(json_string), options)\n end",
"def serialize(method = :to_json)\n super\n end",
"def apply_json_trait(value); end",
"def supports_json?\n false\n end",
"def supports_json?\n false\n end",
"def get_json\n return to_json()\nend",
"def _to_json_struct\n raise NoMethodError, \"subclasses must implement #{__method__}\"\n end",
"def with_serializer(object, serializer); end",
"def to_json\n raise StandardError, \"Not implemented!\"\n end",
"def to_json_raw_object()\n #This is a stub, used for indexing\n end",
"def print_json_obj\n \n end",
"def json_to_object(json)\n JSON(json)\nend",
"def eql_json(expected)\n JSONSpectacular::Matcher.new(expected)\n end",
"def serializer=(_arg0); end",
"def get_one\n serialize_test\n end",
"def serialize(object) end",
"def serialize; end",
"def serialize; end",
"def j(obj)\n puts obj.to_json\nend",
"def serialize!\n end",
"def test_render_using_implicit_serializer\n get :render_using_implicit_serializer\n\n assert_equal 'application/json', @response.content_type\n assert_equal '{\"name\":\"Name 1\",\"description\":\"Description 1\"}', @response.body\n end",
"def as_json(_opts={})\n raise NotImplementedError\n end",
"def test_cli_automation_interface\n # assert_respond_to(SakaiInfo::User, :all_serializations)\n # u = fetch_user_object\n # SakaiInfo::User.all_serializations.each do |s|\n # method_name = \"#{s.to_s}_serialization\".to_sym\n # assert_respond_to(u, method_name)\n # end\n end",
"def deserialize(data, method = :from_json)\n super\n end",
"def parse_json_custom(object, options)\n # p \"SerializableResource, parse_json_custom, object, options\" + object.to_s + \" \" + options.to_s\n # ActiveModelSerializers::SerializableResource.new(object).as_json\n # Able to access at serializer level as @instance_options\n ActiveModelSerializers::SerializableResource.new(object, options).as_json\n end",
"def serialize_json(o)\n API_CLIENT.object_to_http_body(o)\nend",
"def deserialize(json)\n raise NotImplementedError\n end",
"def serialize\n \n end",
"def jsonify(input); end",
"def json_should_eql(actual, expected)\n same = json_cmp(actual, expected)\n actual.should.== expected unless same \nend",
"def serialize(object, data); end",
"def GameData2JSON(this, is_not, a_method)\n raise 'Don\\'t call that'\nend",
"def test_as_json_object_null\n obj = Orange.new(true, 58)\n json = Oj.dump(obj, :mode => :null)\n assert_equal('null', json)\n end",
"def method_missing(method_name, *args, &block)\n @json.__send__(method_name, *args, &block)\n end",
"def getActualJsonObject()\n return $jsonObjectMain\nend",
"def json?\n raw_options[:format] == :json\n end",
"def e(object)\n require 'json'\n object.respond_to?(:to_json) ? object.to_json : object.to_s.to_json\n end",
"def raw_json(*)\n # We need to pass no arguments to `Oj::StringWriter` because it expects 0 arguments\n # because its method definition `oj_dump_raw_json` defined in the C classes is defined\n # without arguments. Oj gets confused because it checks if the class is `Oj::StringWriter`\n # and if it is, then it passes 0 arguments, but when it's not (e.g. `NonBlankJsonWriter`)\n # then it passes both. So in this case, we're calling super() to `Oj::StringWriter` with\n # two arguments.\n #\n # https://github.com/ohler55/oj/commit/d0820d2ac1a72584329bc6451d430737a27f99ac#diff-854d0b67397d7006482043d1202c9647R532\n super()\n end",
"def serialize\n raise NotImplementedError\n end",
"def serialize\n raise NotImplementedError\n end",
"def object_to_json(obj)\n JSON(obj)\nend",
"def serialize(json, serialize_context: self.class.new_serialize_context)\n ViewModel::Callbacks.wrap_serialize(self, context: serialize_context) do\n serialize_view(json, serialize_context: serialize_context)\n end\n end",
"def stringify\n json_hash = {}\n\n begin\n json_hash = Serializer.serialize(self, class: self.class.name)\n rescue JSON::JSONError => e\n warn \"#{__FILE__}.#{__LINE__}: #{e.message}\"\n end\n\n json_hash.to_json\n end",
"def as_json(*)\n {\n FunJSON.create_id => self.class.name,\n 'b' => _dump,\n }\n end",
"def as_json(*)\n {\n JSON.create_id => self.class.name,\n 'b' => _dump,\n }\n end",
"def deserialized?\n true\n end",
"def format\n :json\n end",
"def test_json_deserialize_short_tag\n new_entry = EntryCrypto::PasswordEntry.new\n new_user = EntryCrypto::User.new \"master_user\", 1234, \"Some secret here\"\n\n new_user.lock(\"fake_pass\")\n new_user.unlock(\"fake_pass\")\n\n result = new_entry.from_json '{\"json_class\":\"PasswordEntry\",\"iv\":\"d4d2c2617dd3cb9c716571f9\",\"user_name\":\"test_user\",\"site_name\":\"www.google.ca\",\"encrypted_password\":\"201894205d3f112fefa1e7f7\",\"auth_tag\":\"a7a81df2c3528a5a345230b0392793\"}'\n\n assert result == false\n assert new_entry.user_name.nil?\n assert new_entry.site_name.nil?\n assert new_entry.encrypted_password.nil?\n assert new_entry.iv.nil?\n assert new_entry.auth_tag.nil?\n end",
"def test_1_verify_data_output_to_new_json_file\n user_hash = {\"user_name\"=>\"Abby\",\"user_age\"=>\"20\",\"num_1\"=>\"2\",\"num_2\"=>\"4\",\"num_3\"=>\"6\"}\n write_json(user_hash)\n result = read_json()\n assert_equal([{\"user_name\"=>\"Abby\",\"user_age\"=>\"20\",\"num_1\"=>\"2\",\"num_2\"=>\"4\",\"num_3\"=>\"6\"}], result)\n end",
"def augment_new_json(json)\n json\n end",
"def test_object_null\n obj = Jam.new(true, 58)\n json = Oj.dump(obj, :mode => :null)\n assert_equal('null', json)\n end",
"def test_json_echo()\n # Parameters for the API call\n input = JSON.parse('{\"uid\": \"1123213\", \"name\": \"Shahid\"}')\n\n # Perform the API call through the SDK function\n result = self.class.controller.json_echo(input)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 200)\n\n # Test whether the captured response is as we expected\n assert_not_nil(result)\n expected_body = JSON.parse('{\"body\": {\"uid\": \"1123213\", \"name\": \"Shahid\"}}')\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def serialize(_object, data); end",
"def serialize(_object, data); end",
"def jsonifiable\n @jsonifiable ||= Body.new(catch(:jsonifiable) do\n original_body = self.body\n unless original_body.is_a?(String)\n begin\n # if the response body is not a string, but JSON doesn't complain \n # about dumping whatever it is, go ahead and use it\n JSON.generate([original_body])\n throw :jsonifiable, original_body\n rescue\n # otherwise return nil - don't know what to do with whatever this object is \n throw :jsonifiable, nil\n end\n end\n\n # first try to change the string's encoding per the Content-Type header \n body = original_body.dup\n unless body.valid_encoding?\n # I think this always comes in as ASCII-8BIT anyway so may never get here. hopefully.\n body.force_encoding('ASCII-8BIT')\n end\n\n content_type_attrs = ContentTypeAttrs.new(content_type)\n if content_type_attrs.parsed?\n charset = content_type_attrs['charset'].first\n if charset && Encoding.list.any? { |enc| enc.to_s.downcase == charset.downcase }\n if body.dup.force_encoding(charset).valid_encoding?\n body.force_encoding(charset)\n else\n # I guess just ignore the specified encoding if the result is not valid. fall back to \n # something else below.\n end\n end\n end\n begin\n JSON.generate([body])\n rescue Encoding::UndefinedConversionError\n # if updating by content-type didn't do it, try UTF8 since JSON wants that - but only \n # if it seems to be valid utf8. \n # don't try utf8 if the response content-type indicated something else. \n try_utf8 = !(content_type_attrs && content_type_attrs.parsed? && content_type_attrs['charset'].any? { |cs| !['utf8', ''].include?(cs.downcase) })\n if try_utf8 && body.dup.force_encoding('UTF-8').valid_encoding?\n body.force_encoding('UTF-8')\n else\n # I'm not sure if there is a way in this situation to get JSON gem to generate the \n # string correctly. fall back to an array of codepoints I guess? this is a weird \n # solution but the best I've got for now. \n body = body.codepoints.to_a\n end\n end\n body\n end, content_type)\n end",
"def test_serialize_non_ascii_data_to_json\n data = {\"foo\" => \"\\u3042\\u4e9c\\u03b1\"}\n driver = create_driver('')\n assert_equal(%q({\"foo\":\"\\u3042\\u4e9c\\u03b1\"}), driver.instance.to_json(data))\n end",
"def to_json(*args); end",
"def json\n @json || perform and @json\n end",
"def json(obj)\n JSON.create_id = nil\n JSON.pretty_generate(obj)\nend",
"def json\n \"#{self.to_s}&json=true\"\n end",
"def render_json\n end",
"def json_obj(method,params={})\n obj =\n {\n 'jsonrpc'=>'2.0',\n 'method'=>method,\n 'params'=>params,\n 'auth'=>@auth,\n 'id'=>@id\n }\n debug(10, :msg=>\"json_obj: #{obj}\")\n return obj.to_json\n end",
"def as_json(*)\n to_ims_tool_proxy\n end",
"def test_should_be_json_response\n get '/mock/example'\n assert_equal last_response.content_type, \"application/json\"\n end",
"def assert_object\n assert_response :success\n assert_kind_of Hash, json_response\n assert_kind_of Integer, json_response[\"id\"]\n end",
"def serialize\n marshall.to_json\n end",
"def test_json_deserialize\n new_entry = EntryCrypto::PasswordEntry.new\n new_user = EntryCrypto::User.new \"master_user\", 1234, \"12345678901234567890123456789012\"\n\n new_user.lock(\"fake_pass\")\n new_user.unlock(\"fake_pass\")\n\n result = new_entry.from_json '{\"json_class\":\"PasswordEntry\",\"iv\":\"f28ac40a30d46674a34c8b9c\",\"user_name\":\"test_user\",\"site_name\":\"www.google.ca\",\"encrypted_password\":\"e536c732d1d1785c157e079d\",\"auth_tag\":\"0a117b90b082a633285e569b2f0f7606\",\"salt\":\"bafb2053f8eba9a34a1019a47096424da985620fa169d9d7bef1e1adb788b51bbb356fa171ec8bba62b3acb1baa414773706124619bf8c8ac414594a1e440f56\"}'\n\n assert result == true\n assert new_entry.site_name == \"www.google.ca\"\n assert new_entry.user_name == \"test_user\"\n\n decrypted_password = new_entry.unlock_password(new_user)\n\n assert decrypted_password == \"password1234\"\n end",
"def readable_json(json)\n\t\t JSON.parse(json) rescue nil\n\t\tend",
"def __convert_to_json(o=nil, options={})\n o = o.is_a?(String) ? o : serializer.dump(o, options)\n end",
"def serialized?\n false\n end",
"def to_json\n\n end",
"def serialize(target, json, serialize_context: new_serialize_context)\n case target\n when ViewModel\n target.serialize(json, serialize_context: serialize_context)\n when Array\n json.array! target do |elt|\n serialize(elt, json, serialize_context: serialize_context)\n end\n when Hash, Struct\n json.merge!({})\n target.each_pair do |key, value|\n json.set! key do\n serialize(value, json, serialize_context: serialize_context)\n end\n end\n else\n json.merge! target\n end\n end",
"def as_json(*_args)\n as_extended_json\n end",
"def serialized\n serializer_class.new(self).serializable_hash\n end",
"def to_json_raw(*args)\n #This is a stub, used for indexing\n end",
"def serialize(*args, &block); end",
"def serialize(*args, &block); end",
"def test_php_serialization\n err = assert_compile 'php_serialization.y'\n assert_no_warnings err\n assert_parser_unchanged 'php_serialization.y'\n end",
"def serialize\n end",
"def to_json arg\n as_json.to_json\n end",
"def inspect\n '#<JsonObj>'\n end",
"def inspect\n '#<JsonObj>'\n end",
"def default_engine\n :ok_json\n end",
"def to_json(*_arg0); end",
"def to_json(*_arg0); end",
"def to_json\n @json ||= get_json\n end",
"def is_json?(json)\n begin\n JSON.parse(json)\n return true\n rescue Exception => e\n return false\n end\nend",
"def json_request?()\n request.format.json?\n end",
"def serialize\n JSON.generate(to_h)\n end",
"def json\n add option: \"-json\"\n end",
"def initialize(json)\n @json = json\n end",
"def testable_response(response)\n JSON.parse(response.body)\n end",
"def test_wrap_body_in_object()\n # Parameters for the API call\n field = 'QA'\n name = 'farhan'\n\n # Perform the API call through the SDK function\n result = @controller.wrap_body_in_object(field, name)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end"
] |
[
"0.7805911",
"0.69619346",
"0.6739729",
"0.66873354",
"0.6620401",
"0.6599065",
"0.65728134",
"0.6468269",
"0.6407441",
"0.6369593",
"0.6353084",
"0.6353084",
"0.6339046",
"0.6292706",
"0.6286541",
"0.628575",
"0.6185708",
"0.61709976",
"0.6147885",
"0.60945326",
"0.6090455",
"0.6079995",
"0.6060325",
"0.6052027",
"0.6052027",
"0.60476226",
"0.6027839",
"0.6021122",
"0.6019987",
"0.60177505",
"0.60075873",
"0.5996639",
"0.59519356",
"0.59198725",
"0.59085643",
"0.5889297",
"0.5883971",
"0.58817106",
"0.5879139",
"0.58786374",
"0.5861402",
"0.5848783",
"0.5845852",
"0.5844623",
"0.58403826",
"0.58287996",
"0.58287996",
"0.58228993",
"0.5803744",
"0.58019984",
"0.57923424",
"0.57722044",
"0.5759544",
"0.57392323",
"0.5729123",
"0.5719181",
"0.57108766",
"0.56998026",
"0.5696451",
"0.569049",
"0.569049",
"0.5672326",
"0.5669373",
"0.56336105",
"0.5623358",
"0.5613272",
"0.56120956",
"0.56105816",
"0.560916",
"0.559031",
"0.5584572",
"0.55773014",
"0.5572928",
"0.55710375",
"0.55655366",
"0.5560987",
"0.5554489",
"0.55490106",
"0.5528156",
"0.55208665",
"0.5515587",
"0.5512218",
"0.5501786",
"0.5501786",
"0.5491771",
"0.5489841",
"0.548267",
"0.5479386",
"0.5479386",
"0.5475014",
"0.54692334",
"0.54692334",
"0.54685116",
"0.54663646",
"0.5464354",
"0.5455954",
"0.54556",
"0.54538363",
"0.5451913",
"0.54419893"
] |
0.6708164
|
3
|
Test the old CamelCase method names
|
def test_old_camelCase_method_names
setup_test_tree
meth_names_to_test = %w{isRoot? isLeaf? hasContent?
hasChildren? setAsRoot! firstChild lastChild
firstSibling isFirstSibling? lastSibling isLastSibling?
isOnlyChild? nextSibling previousSibling nodeHeight nodeDepth
createDumpRep removeFromParent! removeAll! freezeTree! }
require 'structured_warnings'
DeprecatedMethodWarning.disable do
assert(@root.isRoot?) # Test if the original method is really called
end
meth_names_to_test.each do |meth_name|
assert_warn(DeprecatedMethodWarning) {@root.send(meth_name)}
end
# Special Case for printTree to avoid putting stuff on the STDOUT during the unit test.
begin
require 'stringio'
$stdout = StringIO.new
assert_warn(DeprecatedMethodWarning) { @root.send('printTree') }
ensure
$stdout = STDOUT
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_camel_case\n raise NotImplementedError, 'Undecided as to whether to check camel case or not'\n end",
"def test_Method_InstanceMethods_meth\n\t\tmethod = \"cat\".method(:upcase)\n\t\tassert_equal(\"upcase\", method.name.to_s)\n\tend",
"def camel_case_method?\n method_name.to_s =~ /\\A[A-Z]/\n end",
"def sanitize_method_name( name )\n name.to_s.camelize\n end",
"def downcase!() end",
"def upcase!() end",
"def downcase() end",
"def downcase; end",
"def camelize_methodname\n self.titleize.gsub(' ', '').camelize(:lower)\n end",
"def upcase() end",
"def upcase; end",
"def snake_case(name); end",
"def swapcase!() end",
"def downcase_name\n name.downcase!\n end",
"def camel_case(str); end",
"def swapcase() end",
"def name_case!\n self.gsub!(self, self.name_case)\n end",
"def test_downcase\n value = \"XYZ\"\n assert_equal \"xyz\", value.downcase\n end",
"def camelcase(s)\n\n\nend",
"def capitalize!() end",
"def test_downcase\n value = 'XyZ'\n assert_equal('xyz', value.downcase)\n end",
"def test_downcase\n value = 'XyZ'\n assert_equal('xyz', value.downcase)\n end",
"def test_downcase\n value = 'XyZ'\n assert_equal('xyz', value.downcase)\n end",
"def validate_method_name(name)\n KeyWords.include?(name) ? \"do#{name.gsub(/-/, \"_\").camelcase}\" : validate_property_name(name)\n end",
"def camel_case\n gsub /(?:^|_)(.)/ do $1.upcase end\n end",
"def capitalize\n \"Foo\"\n end",
"def capitalize() end",
"def upcase\n @name.upcase\n end",
"def downcase_keys\n end",
"def underscorize!\n self.replace(self.scan(/[A-Z][a-z]*/).join(\"_\").downcase)\n end",
"def instance_method(arg)\n arg.upcase\nend",
"def is_uppercase?(word)\nend",
"def test_other_than_first_character\n %w( iTunes TitleCase ).each do |word|\n assert_equal word, word.titlecase\n end\n end",
"def case_fix(name)\r\n fixed_name = name.split(' ')\r\n fixed_name.each do |word|\r\n word.capitalize!\r\n end\r\n fixed_name.join(' ')\r\nend",
"def test_old_camelCase_method_names\n @left_child2 = Tree::BinaryTreeNode.new(\"A Child at Left\", \"Child Node @ left\")\n @right_child2 = Tree::BinaryTreeNode.new(\"B Child at Right\", \"Child Node @ right\")\n\n require 'structured_warnings'\n\n meth_names_for_test = %w{leftChild isLeftChild? rightChild isRightChild?}\n\n meth_names_for_test.each do |meth_name|\n assert_warn(DeprecatedMethodWarning) {@root.send(meth_name)}\n end\n\n assert_warn(DeprecatedMethodWarning) {@root.leftChild = @left_child2}\n assert_warn(DeprecatedMethodWarning) {@root.rightChild = @right_child2}\n\n end",
"def genability_method_name_converter(method_name)\n method_name.to_s.gsub(/(?:^|_)(.)/){ $1.upcase }.gsub(/^[A-Z]/){ $&.downcase }.to_sym\n end",
"def lowercase_name\n name.downcase\n end",
"def parse_method(method)\n method.downcase.to_sym\n end",
"def name_case(options = {})\n options = { :lazy => true, :irish => true }.merge options\n\n # Skip if string is mixed case\n if options[:lazy]\n first_letter_lower = self[0] == self.downcase[0]\n all_lower_or_upper = (self.downcase == self || self.upcase == self)\n\n return self unless first_letter_lower || all_lower_or_upper\n end\n\n localstring = downcase\n localstring.gsub!(/\\b\\w/) { |first| first.upcase }\n localstring.gsub!(/\\'\\w\\b/) { |c| c.downcase } # Lowercase 's\n\n if options[:irish]\n if localstring =~ /\\bMac[A-Za-z]{2,}[^aciozj]\\b/ or localstring =~ /\\bMc/\n match = localstring.match(/\\b(Ma?c)([A-Za-z]+)/)\n localstring.gsub!(/\\bMa?c[A-Za-z]+/) { match[1] + match[2].capitalize }\n\n # Now fix \"Mac\" exceptions\n localstring.gsub!(/\\bMacEdo/, 'Macedo')\n localstring.gsub!(/\\bMacEvicius/, 'Macevicius')\n localstring.gsub!(/\\bMacHado/, 'Machado')\n localstring.gsub!(/\\bMacHar/, 'Machar')\n localstring.gsub!(/\\bMacHin/, 'Machin')\n localstring.gsub!(/\\bMacHlin/, 'Machlin')\n localstring.gsub!(/\\bMacIas/, 'Macias')\n localstring.gsub!(/\\bMacIulis/, 'Maciulis')\n localstring.gsub!(/\\bMacKie/, 'Mackie')\n localstring.gsub!(/\\bMacKle/, 'Mackle')\n localstring.gsub!(/\\bMacKlin/, 'Macklin')\n localstring.gsub!(/\\bMacKmin/, 'Mackmin')\n localstring.gsub!(/\\bMacQuarie/, 'Macquarie')\n end\n localstring.gsub!('Macmurdo','MacMurdo')\n end\n\n # Fixes for \"son (daughter) of\" etc\n localstring.gsub!(/\\bAl(?=\\s+\\w)/, 'al') # al Arabic or forename Al.\n localstring.gsub!(/\\bAp\\b/, 'ap') # ap Welsh.\n localstring.gsub!(/\\bBen(?=\\s+\\w)/,'ben') # ben Hebrew or forename Ben.\n localstring.gsub!(/\\bDell([ae])\\b/,'dell\\1') # della and delle Italian.\n localstring.gsub!(/\\bD([aeiou])\\b/,'d\\1') # da, de, di Italian; du French; do Brasil\n localstring.gsub!(/\\bD([ao]s)\\b/,'d\\1') # das, dos Brasileiros\n localstring.gsub!(/\\bDe([lr])\\b/,'de\\1') # del Italian; der Dutch/Flemish.\n localstring.gsub!(/\\bEl\\b/,'el') # el Greek or El Spanish.\n localstring.gsub!(/\\bLa\\b/,'la') # la French or La Spanish.\n localstring.gsub!(/\\bL([eo])\\b/,'l\\1') # lo Italian; le French.\n localstring.gsub!(/\\bVan(?=\\s+\\w)/,'van') # van German or forename Van.\n localstring.gsub!(/\\bVon\\b/,'von') # von Dutch/Flemish\n\n # Fix roman numeral names\n localstring.gsub!(\n / \\b ( (?: [Xx]{1,3} | [Xx][Ll] | [Ll][Xx]{0,3} )?\n (?: [Ii]{1,3} | [Ii][VvXx] | [Vv][Ii]{0,3} )? ) \\b /x\n ) { |match| match.upcase }\n\n localstring\n end",
"def snakecase(string); end",
"def titlecase!\n replace(titlecase)\n end",
"def upcase(s)\n s.upcase!\n true\nend",
"def downcase!\n @raw.downcase!\n end",
"def camel_case?(allow_prefixed_underscores: true)\n LuckyCase.camel_case? self, allow_prefixed_underscores: allow_prefixed_underscores\n end",
"def test_downcase\n assert_equal 'xyz', value.downcase\nend",
"def un_camelcase( s )\n s.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def mixed_case(name)\n name.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def downcase(input); end",
"def specialize_method_name( name )\n return \"#{name}#{self.class.name.split(\"::\")[-1].gsub(/[A-Z]/){|s| \"_#{s.downcase}\"}}\".intern\n end",
"def downcase\n (self.to_s.downcase! || self).to_sym\n end",
"def downcase_fields\n self.handle.downcase!\n end",
"def upcase(input); end",
"def test_to_capitalize_every_other_character_with_capitalized_characters\nresult = capitalize_every_other(\"SHaWn\")\nassert_equal(\"ShAwN\", result)\nend",
"def downcase_fields\n self.guess.downcase!\n end",
"def downcase!\n self.username.downcase!\n self.email.downcase!\n end",
"def camel_case(name)\n if name.include? '_'\n name.split('_').map{|e| e.capitalize}.join\n else\n unless name =~ (/^[A-Z]/)\n name.capitalize\n else\n name\n end\n end\nend",
"def mixed_case_2(name)\n\tname.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def lower_case!(words)\n raise NotImplementedError # TODO\nend",
"def camelize!\n self.titleize!\n self.replace(self[0, 1].downcase + self[1..-1])\n end",
"def name\n camel = self.class.to_s.gsub(/.*::/, '')\n camel.gsub(/(\\S)([A-Z])/, '\\1_\\2').downcase\n end",
"def test_to_normal(name, klassname=nil)\n unmunge(name.to_s.sub(/^test_/, '')) do |n|\n if defined? @inherited_methods then\n known_methods = (@inherited_methods[klassname] || {}).keys.sort.reverse\n known_methods_re = known_methods.map {|s| Regexp.escape(s) }.join(\"|\")\n n = n.sub(/^(#{known_methods_re})(_.*)?$/) { $1 } unless\n known_methods_re.empty?\n n\n end\n end\n end",
"def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @subtitle = StringUtils.mixed_case(@subtitle)\n @genre = StringUtils.mixed_case(@genre)\n @mixer = StringUtils.mixed_case(@mixer)\n @version_name = StringUtils.mixed_case(@version_name)\n @version_name.gsub!(/(\\A|\\s)(Version|Release)\\b/) {|string| string.downcase} if @version_name\n end",
"def aliased_method_name(method_name)\r\n last_letter = method_name.to_s[method_name.to_s.size-1]\r\n if %w(? !).member? last_letter\r\n # remove ? and ! from the middle and put it to the end\r\n (method_name.to_s.chop!+\"_in_#{self.simple_name.to_snake_case}#{last_letter}\").to_sym\r\n else\r\n (method_name.to_s+\"_in_#{self.simple_name.to_snake_case}\").to_sym\r\n end\r\n end",
"def test_downcase_string\n test = 'MiXeD'\n down = test.downcase\n assert_equal down, 'mixed'\n end",
"def capitalize(word)\n\nend",
"def upcase?(string)\n string == string.upcase\nend",
"def is_lower?(c)\n return c != c.capitalize\n end",
"def letter_cases(allow_prefixed_underscores: true)\n LuckyCase.cases self, allow_prefixed_underscores: allow_prefixed_underscores\n end",
"def downcase\n\t\tcollect(&:downcase)\n\tend",
"def upcase\n (self.to_s.upcase! || self).to_sym\n end",
"def capitalized\n name.titleize.capitalize\n end",
"def bar(s)\n s.upcase\nend",
"def getMethodName(description)\n description[0] = description[0].downcase\n description.to_s.gsub(' ', '')\n end",
"def snake_case(name)\n name.gsub(/([a-z])([A-Z0-9])/, '\\1_\\2' ).downcase\nend",
"def spy_name(real_name)\n capitalize(next_letter(swap(real_name)))\nend",
"def ga_to_method_name(name)\n snakecase(name.gsub(/\\Aga:/, \"\")).to_sym\n end",
"def uppercase_name\n # self.name.upcase\n name.upcase #self is the implicit reciever\n end",
"def fdowncase\n downcase.cdowncase\n end",
"def upper_case()\n LuckyCase.upper_case self\n end",
"def downcase\n `return self.toLowerCase();`\n end",
"def downcase\n `return self.toLowerCase();`\n end",
"def is_upper? str; str == str.upcase; end",
"def strip_and_downcase_name\n if name.present?\n name.strip!\n name.downcase!\n end\n end",
"def method_missing(meth, *args, &block)\n # method in Ruby are all lowercase...\n if meth.to_s =~ /_[a-z0-9]+_order/\n STDERR.print(\"[!] method #{meth} not defined yet...\\n\")\n Kernel.exit 1\n else\n super\n end\n end",
"def camel_case\n return self if self !~ /_/ && self =~ /[A-Z]+.*/\n split('_').map{|e| e.capitalize}.join\n end",
"def camel_case\n return self if self !~ /_/ && self =~ /[A-Z]+.*/\n split('_').map{|e| e.capitalize}.join\n end",
"def under_attack\n puts \"THE world is in danger due to the evil taking over!!!\".upcase\nend",
"def name_this_method(word)\n\tword[0] = word[0].upcase\nend",
"def snakecase(name)\n name.gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').downcase\n end",
"def test_Method_InstanceMethods_receiver\n\t\tmethod = \"cat\".method(:upcase)\n\t\t# TODO, assert_equal(\"cat\", method.receviver)\n\tend",
"def change_case( answer_string )\n if [:up, :upcase].include?(@case)\n answer_string.upcase\n elsif [:down, :downcase].include?(@case)\n answer_string.downcase\n elsif @case == :capitalize\n answer_string.capitalize\n else\n answer_string\n end\n end",
"def to_camel_case\n return self if self !~ /_/ && self !~ /\\s/ && self =~ /^[A-Z]+.*/\n\n gsub(/[^a-zA-Z0-9ññÑáéíóúÁÉÍÓÚüÜ_]/, \"_\")\n .split(\"_\").map(&:capitalize).join\n end",
"def snake_case(str); end",
"def name= string\n super(string ? string.downcase : string)\n end",
"def snake_case\n return downcase if match(/\\A[A-Z]+\\z/)\n gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').\n gsub(/([a-z])([A-Z])/, '\\1_\\2').\n downcase\n end",
"def capitalize_name(name)\n name.call\nend",
"def fupcase\n upcase.cupcase\n end",
"def lower_case(words)\n raise NotImplementedError # TODO\nend",
"def titlecase()\r\n ignore_list = %w{of etc and by the for on is at to but nor or a via}\r\n capitalize_all_ex(ignore_list)\r\n end",
"def test_tablenames_with_hyphens\n end"
] |
[
"0.8006875",
"0.74762756",
"0.74658036",
"0.7402534",
"0.73579395",
"0.73183393",
"0.72632813",
"0.7260595",
"0.7260355",
"0.725124",
"0.7186343",
"0.7172299",
"0.71242326",
"0.71216244",
"0.7116901",
"0.7079842",
"0.70731884",
"0.7030736",
"0.7020418",
"0.6991513",
"0.6911323",
"0.6911323",
"0.6911323",
"0.69088966",
"0.67996275",
"0.6761633",
"0.6719138",
"0.6716177",
"0.66545045",
"0.6648644",
"0.663487",
"0.65995204",
"0.659008",
"0.65795666",
"0.6541257",
"0.6527156",
"0.65241873",
"0.65213686",
"0.6517855",
"0.6508277",
"0.65056694",
"0.64992726",
"0.6498977",
"0.6498523",
"0.6495293",
"0.6478798",
"0.64603806",
"0.64601284",
"0.6454009",
"0.6441832",
"0.64284384",
"0.64220744",
"0.6421646",
"0.6413834",
"0.64136446",
"0.64045554",
"0.64042044",
"0.6398834",
"0.63947153",
"0.63934594",
"0.6389135",
"0.63683623",
"0.63616824",
"0.63541025",
"0.63464147",
"0.6339566",
"0.6337852",
"0.63342875",
"0.633216",
"0.63241434",
"0.63240844",
"0.63235265",
"0.63182026",
"0.6303068",
"0.6300559",
"0.62950844",
"0.62812954",
"0.6280208",
"0.62694293",
"0.62668014",
"0.62668014",
"0.6254892",
"0.6246025",
"0.6236902",
"0.6234567",
"0.6234567",
"0.62336266",
"0.623322",
"0.6226627",
"0.6224433",
"0.6220003",
"0.6217389",
"0.62103516",
"0.6206567",
"0.61879003",
"0.6184228",
"0.6179141",
"0.61789876",
"0.617754",
"0.6173812"
] |
0.6928734
|
20
|
Test usage of integers as node names
|
def test_integer_node_names
require 'structured_warnings'
assert_warn(StandardWarning) do
@n_root = Tree::TreeNode.new(0, "Root Node")
@n_child1 = Tree::TreeNode.new(1, "Child Node 1")
@n_child2 = Tree::TreeNode.new(2, "Child Node 2")
@n_child3 = Tree::TreeNode.new("three", "Child Node 3")
end
@n_root << @n_child1
@n_root << @n_child2
@n_root << @n_child3
# Node[n] is really accessing the nth child with a zero-base
assert_not_equal(@n_root[1].name, 1) # This is really the second child
assert_equal(@n_root[0].name, 1) # This will work, as it is the first child
assert_equal(@n_root[1, true].name, 1) # This will work, as the flag is now enabled
# Sanity check for the "normal" string name cases. Both cases should work.
assert_equal(@n_root["three", false].name, "three")
StandardWarning.disable
assert_equal(@n_root["three", true].name, "three")
# Also ensure that the warning is actually being thrown
StandardWarning.enable
assert_warn(StandardWarning) {assert_equal(@n_root["three", true].name, "three") }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nodetype2num(x)\n @nodetypes.find_index(x)\nend",
"def visit_node(n); end",
"def gen_node_key(num)\n \"node#{num}\".to_sym\nend",
"def test_access_feature_name\n assert_equal 'krung go', @one_to_nine.child_node.name\n assert_equal 'ཀྲུང་གོ', @one_to_nine.parent_node.name\n end",
"def test_accessing_node_name\n\t\tassert_equal \"Hillman\", @location2.nodes[0].name\n\tend",
"def position_node?(node)\n node.respond_to?(:length) and node.length == 2 and\n node.respond_to?(:all?) and node.all? do |child|\n child.respond_to?(:to_i)\n end\n end",
"def integer?(token)\n token.to_i.to_s == token\n end",
"def number_of_nodes(node_name)\n nodes(node_name).count\nend",
"def position_node?(node)\n node.respond_to?(:length) &&\n node.length == 2 &&\n node.respond_to?(:all?) &&\n node.all? { |child| child.respond_to?(:to_i) }\n end",
"def test_get_node_range_no_features\n nodes = @container.get_nodes('1',12,27,0)\n assert_equal(4, nodes.length)\n assert_equal([11,15,0], [nodes[0].start, nodes[0].stop, nodes[0].count])\n assert_equal([16,20,0], [nodes[1].start, nodes[1].stop, nodes[1].count])\n assert_equal([21,25,1], [nodes[2].start, nodes[2].stop, nodes[2].count])\n assert_equal([26,28,0], [nodes[3].start, nodes[3].stop, nodes[3].count])\n end",
"def test_16\n MiniUniverse.each do |e|\n assert_equal(\"~d\".format(e), \"~A\".format(e)) unless e.respond_to? :to_int\n end\n end",
"def nodeID_check(el, nodeID)\n if NC_REGEXP.match(nodeID)\n nodeID\n else\n add_debug(el, \"nodeID addtribute '#{nodeID}' must be an XML Name\")\n raise RdfContext::ParserException.new(\"nodeID addtribute '#{nodeID}' must be a NCName\") if @strict\n nil\n end\n end",
"def position_node?(node)\n node.respond_to?(:length) and node.length == 2 and node.respond_to?(:all?) and node.all?{|child| child.respond_to?(:to_i)}\n end",
"def position_node?(node)\n node.respond_to?(:length) and node.length == 2 and node.respond_to?(:all?) and node.all?{|child| child.respond_to?(:to_i)}\n end",
"def parse_integer attr_name, xpath\n v = parse_value xpath\n v = v.to_i if v.respond_to?(:to_i)\n send(\"#{attr_name}=\", v)\n end",
"def position_node?(node)\n node.respond_to?(:length) and node.length == 2 and\n node.respond_to?(:all?) and node.all?{|child| child.respond_to?(:to_i)}\n end",
"def position_node?(node)\n node.respond_to?(:length) and node.length == 2 and\n node.respond_to?(:all?) and node.all?{|child| child.respond_to?(:to_i)}\n end",
"def DISABLED_test_parenthetical_integer\n assert_parses_to [LeftParenthesisToken.instance, IntegerToken.new(-1), RightParenthesisToken.instance],\n ExpressionNode.new(\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n LeftParenthesisToken.instance,\n ExpressionNode.new(\n TermNode.new(\n FactorNode.new(\n BaseNode.new(\n IntegerToken.new(-1))),\n TermPrimeNode.new),\n ExpressionPrimeNode.new),\n RightParenthesisToken.instance)),\n TermPrimeNode.new),\n ExpressionPrimeNode.new)\n end",
"def expect_integer name, value\n expect_type name,\n value,\n \"integer\",\n Integer\n end",
"def isDummyNode?(node) \n return node.name == Tag_Dummy ;\n end",
"def node_type() ; info[:node_type] ; end",
"def node_type() ; info[:node_type] ; end",
"def node_is?(node, name)\n node.class.name == \"RKelly::Nodes::#{name}Node\"\n end",
"def DISABLED_test_non_negative_integers\n (0..1000).each do |digit|\n assert_tokenises_as digit.to_s, IntegerToken.new(digit)\n end\n assert_tokenises_as '0 ', IntegerToken.new(0)\n assert_tokenises_as ' 0', IntegerToken.new(0)\n end",
"def generate_tree_id(count)\n if count < 10\n \"000#{count}\"\n elsif count >= 10 && count < 100\n \"00#{count}\"\n elsif count >= 100 && count < 1000\n \"0#{count}\"\n else\n \"#{count}\" \n end\n end",
"def convert_node(n)\n node = \"n%04d\" % @n\n @n += 1\n @graph.node(node).label(n.inspect)\n node\n end",
"def special_number?(literal)\n literal.is_a?(Sass::Script::Value::String) && literal.value =~ /(calc|var)\\(/\n end",
"def test_if_node_has_score_and_title\n node = Node.new(50, \"movie a\")\n assert_equal \"movie a\", node.title\n assert_equal 50, node.score\n end",
"def literal?(node); end",
"def check(node); end",
"def name_prefix\n 'num'\n end",
"def test_initialize_node\n \tassert_equal @n.id, 0\n \tassert_equal @n.neighbors, []\n \tassert_equal @n.string, \"a\"\n end",
"def test_IntegerLiterals_sample02\n assert_equal(\"Fixnum\", 1_000_000_000.class.to_s)\n end",
"def scanned_node?(node); end",
"def valid_node_value?(nodes)\n nodes == [] || array_of(nodes, String)\n end",
"def magic_number?(n)\n n.to_s.split('').each.map {|ch| ch.to_i}.reduce(:+) == 7 \nend",
"def non_zero_digit; end",
"def test_int_check_pass\n assert_equal int_check([]), true # EDGE CASE\n assert_equal int_check(['1']), true # pass\n assert_equal int_check(['1', '1']), true # pass\n assert_equal int_check(['1', '1', '1']), true # pass\n end",
"def num\n name\n end",
"def match_node node, value\n return if ANY_VALUE != node &&\n (Array === value || Hash === value)\n\n if node.class == value.class\n node == value\n\n elsif Regexp === node\n match = node.match value.to_s\n return false unless match\n match = match.size > 1 ? match[1..-1] : match.to_a\n [true, match]\n\n elsif Range === node\n stat = node.include? value.to_i\n match = [value.to_i] if stat\n [stat, match]\n\n elsif ANY_VALUE == node\n [true, [value]]\n\n else\n value.to_s == node.to_s\n end\n end",
"def test_16\n MiniUniverse.each do |e|\n assert_equal(\"~b\".format(e), \"~A\".format(e)) unless e.respond_to? :to_int\n end\n end",
"def node_type; end",
"def node_type; end",
"def magic_number?(n)\r\n \r\nend",
"def integer?\n @kind == :integer_lit || @kind == :integer_exp_lit || @kind == :hex_lit || @kind == :bin_lit\n end",
"def is_static_node?(nodename)\n # Match queue1-st-compute2-1 or queue1-st-compute2-[1-1000] format\n match = nodename.match(/^([a-z0-9\\-]+)-(st|dy)-([a-z0-9\\-]+)-\\[?\\d+[\\-\\d+]*\\]?$/)\n raise \"Failed when parsing Compute nodename: #{nodename}\" if match.nil?\n\n match[2] == \"st\"\nend",
"def test_check_digits_lower_bound\r\n assert_nil @g.check_digits('0123456789/')\r\n end",
"def digit!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n \n # - - - - main rule block - - - -\n # at line 392:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end",
"def is_int(latex, step)\n\tlatex[step+1..step+3].join == \"int\"\nend",
"def start_number?(text = T.unsafe(nil)); end",
"def string_is_integer?(n)\n n == n.to_i.to_s\nend",
"def node_names\n @nodes.values_at *@nodes.each_index.reject {|i| @index_nodes.include? i}\n end",
"def get_digit(node)\n digit = 0\n digit = node.data if node != nil\n digit\nend",
"def [](name)\n name = name.to_sym\n @nodes.detect { |node| node.name == name }\n end",
"def identifier\n num\n end",
"def test_if_node_exists\n node = Node.new(50, \"movie a\")\n assert node\n end",
"def is_a_moo_number?(name) # :nodoc:\n !!(name.to_s.upcase =~ /^\\d?\\d?\\*?[A-Z]\\d\\d[A-Z]$/)\n end",
"def test_node_starts_with_empty_branches\n node = Node.new(50, \"movie a\")\n refute node.left_node\n refute node.right_node\n end",
"def test_check_digits_true\r\n assert_equal true, @g.check_digits('0123456789')\r\n end",
"def left_child_node(index)\n index * 2 + 1\n end",
"def print_non_operators(node)\n return if node == nil\n count_non_operators = 0\n print_non_operators(node.left) #starts recursion -- go left\n if node.value.match(/\\d/) #if digits included\n count_non_operators += 1\n print node.value + \" \" #print value of this node\n # print node.count\n end\n print_non_operators(node.right)#go right\nend",
"def DISABLED_test_negative_integers\n (-1000..-1).each do |digit|\n assert_tokenises_as digit.to_s, IntegerToken.new(digit)\n end\n assert_tokenises_as '-1 ', IntegerToken.new(-1)\n assert_tokenises_as ' -1', IntegerToken.new(-1)\n end",
"def test_valid_block_number\n assert check_block_number('0', 0)\n end",
"def assert_step_number_label(label)\n current_step, total_steps = label.split(\" of \")\n expect(find(\"div.cucumber-mandate-registration-step-number\").text).to eq(\"#{current_step} /#{total_steps}\")\n end",
"def numerics\n /([0-9]*\\w)/\n end",
"def test_number_has_three_in_it\n\t\tassert_equal \"fizz\", FizzBuzz.identify(13)\n\tend",
"def test_string_and_integer_argument\n assert_output(\"Usage:\\nruby word_finder.rb *name_of_file*\\n*name_of_file* should be a file\\n\") {@grapher.make_graph(['wordlist.txt', 1])}\n end",
"def test_numeric_positive\n test_value = RPN.numeric?(6)\n assert_equal(test_value,0)\n end",
"def DISABLED_test_several_numbers\n assert_tokenises_as '1 -2 3. -4.0',\n IntegerToken.new(1),\n IntegerToken.new(-2),\n DecimalToken.new(3),\n DecimalToken.new(-4)\n end",
"def non_printable_node?(node)\n %w[style head title meta script].include?(node.name.downcase)\n end",
"def test_it_exists\n assert_instance_of Node, @node\n end",
"def is_a_number?(word)\n Integer(word) rescue false\nend",
"def object_attribute_is_node?(name)\n %i[\n alias_of\n delegate\n demand_source\n output_capacity_from_demand_of\n source\n ].include?(name)\n end",
"def matches?(node); end",
"def test_num9\n result = numbers?(\"RYANSTANTz18**\")\n assert(result, \"'RYANSTANTz18**' should be valid because it contains a number\")\n end",
"def is_number?(n, m)\n is_int(@map[n][m])\n end",
"def test_int_check_fail\n assert_equal int_check(['k', 'k', 'k']), false # pass\n assert_equal int_check(['a', 's', 'd', 'f']), false # pass\n end",
"def num_i!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n\n\n type = NUM_I\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 46:8: ( '0' .. '9' )+\n # at file 46:8: ( '0' .. '9' )+\n match_count_4 = 0\n while true\n alt_4 = 2\n look_4_0 = @input.peek( 1 )\n\n if ( look_4_0.between?( 0x30, 0x39 ) )\n alt_4 = 1\n\n end\n case alt_4\n when 1\n # at line \n if @input.peek( 1 ).between?( 0x30, 0x39 )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n match_count_4 > 0 and break\n eee = EarlyExit(4)\n\n\n raise eee\n end\n match_count_4 += 1\n end\n\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n\n end",
"def on_numeric(n)\n n\n end",
"def on_numeric(n)\n n\n end",
"def isNumber(text)\r\n @@log.debug(\"XmlRuleVisitor::isNumber\")\r\n @@log.debug(text.inspect)\r\n\r\n if (nil != text.index('.'))\r\n num = text.to_f\r\n if (num.to_s == text)\r\n @@log.debug(\"isNumber: float: #{num.to_s}\")\r\n return num\r\n end # if num\r\n end # if nil\r\n\r\n num = text.to_i\r\n if (num.to_s == text)\r\n @@log.debug(\"isNumber: int: #{num.to_s}\")\r\n return num\r\n end # if num\r\n\r\n return nil\r\n\r\n end",
"def not_so_useful_match_as(x)\n case x\n in 0..5 => little_number\n puts \"#{little_number} is a pretty small number\"\n in String => string\n puts \"#{string} is a string\"\n in Hash => hash\n puts \"#{hash} is a hash\"\n end\nend",
"def test_display_invalid_ruby\r\n assert_raises('rubyist_num must be an integer!') { @g.display_rubies(1, 1, 'a', 2) }\r\n end",
"def handle_int(int, lineno_column)\n Literal.new int.to_i\n end",
"def nodes_binary_value\n binary = '0' * @nodes.map(&:id).max\n\n @nodes.each do |node|\n binary[@nodes.count - node.id] = '1'\n end\n\n binary\n end",
"def check(mesg, keys) \n # special case, generalizes identifiers and numbers\n if @sy.type == TokenType::IDENT_TOKEN\n test = \"identifier\"\n elsif @sy.type == TokenType::INTEGER_TOKEN\n test = \"integer\"\n elsif @sy.type == TokenType::STRING_TOKEN\n test = \"string\"\n else\n test = @sy.text\n end\n \n if not keys.include? test\n error(mesg, keys)\n end\n end",
"def check_children(value, node)\n if value < node.value\n node.left\n else\n node.right\n end\n end",
"def test_gen_ipaddr_with_prefix\n PROTOCOL_TYPES.keys.each do |protocol|\n ipaddr = RFauxFactory.gen_ipaddr(protocol: protocol, prefix: [10, 11])\n assert ipaddr.split(PROTOCOL_SEPARATOR[protocol]).length, PROTOCOL_TYPES[protocol]\n assert_includes ipaddr.split(PROTOCOL_SEPARATOR[protocol]), '10'\n end\n end",
"def test_error_number\n tokenizer = Tokenizer.new\n tokenizer.text = \"20.000 0767 431abc\"\n tokenizer.tokenize\n tokens = tokenizer.tokens\n\n assert_equal(\"ErrorToken\", tokens[1].class.name)\n assert_equal(\"ErrorToken\", tokens[2].class.name)\n assert_equal(\"20.0\", tokens.first.val)\n assert_equal(\"00\", tokens[1].val)\n assert_equal(\"0\", tokens[2].val)\n assert_equal(\"431\", tokens[4].val)\n end",
"def test_mozilla_pseudo_element_name_within\n doc = CSSPool.CSS <<-eocss\n treechildren::-moz-tree-cell-text() { background: red; }\n eocss\n rs = doc.rule_sets.first\n assert_equal '-moz-tree-cell-text', rs.selectors.first.simple_selectors.first.additional_selectors.first.name\n end",
"def validate_node!\n if @name_args[0].nil?\n ui.error(\"You must specify a node name\")\n show_usage\n exit 1\n end\n end",
"def test_num10\n result = numbers?(\"ryaNStantz**\")\n refute(result, \"'ryaNStantz**' should not be valid because it does not contain a number\")\n end",
"def test_is_nummeric\n assert(StringChecker.is_numeric?(\"+20\"))\n assert(StringChecker.is_numeric?(\"-020\"))\n assert(StringChecker.is_numeric?(\"123\"))\n assert(StringChecker.is_numeric?(\"0123\"))\n assert(!StringChecker.is_numeric?(\"1.2\"))\n assert(!StringChecker.is_numeric?(\"asdf\"))\n assert(!StringChecker.is_numeric?(\" \"))\n end",
"def test_check_for_num_or_x\r\n\t\tisbn_number = '123456789x'\r\n\t\tassert_equal(true, check_for_x(isbn_number))\r\n\tend",
"def local_variable_defined_for_node?(node, name); end",
"def get_int(attr); end",
"def node(name)\n name = name.to_sym\n @nodes.detect{|node|\n node.name == name\n }\n end",
"def find_value_given_node_no(node_num)\n value_given_node_no_support(node_num)\n end",
"def test_8_accepts_includes_numbers\n result = includes_number?(\"Hat123!!\")\n assert(result, \"Hat123!! has non alphanumeric, should be valid\")\n end",
"def is_nodetype?(); @type == GRT_NODETYPE; end"
] |
[
"0.5880383",
"0.57831836",
"0.576323",
"0.5723512",
"0.5706851",
"0.54743654",
"0.5442897",
"0.54287714",
"0.53955",
"0.53803945",
"0.53787047",
"0.5362258",
"0.5346841",
"0.5346841",
"0.53371245",
"0.533357",
"0.533357",
"0.5321807",
"0.52802956",
"0.5262876",
"0.526039",
"0.526039",
"0.52490264",
"0.52353626",
"0.5221188",
"0.5218647",
"0.52055544",
"0.5199609",
"0.5196211",
"0.51953036",
"0.51896256",
"0.5180518",
"0.51759464",
"0.5164721",
"0.5161112",
"0.5137274",
"0.5126355",
"0.5108196",
"0.51075685",
"0.5106524",
"0.5100089",
"0.5096071",
"0.5096071",
"0.5094488",
"0.50832903",
"0.50825894",
"0.5076926",
"0.5073552",
"0.5057687",
"0.50488067",
"0.50430566",
"0.5032753",
"0.5027876",
"0.50177866",
"0.501695",
"0.50163335",
"0.50120544",
"0.5000513",
"0.49982473",
"0.49859774",
"0.49707225",
"0.49656722",
"0.49567255",
"0.49380815",
"0.4933826",
"0.49304232",
"0.4929478",
"0.49252817",
"0.49247903",
"0.49239767",
"0.49213627",
"0.4903927",
"0.4899637",
"0.48971626",
"0.4895264",
"0.48934218",
"0.4892646",
"0.488759",
"0.48811975",
"0.48811975",
"0.48751664",
"0.48739132",
"0.48737708",
"0.4871832",
"0.48700815",
"0.48678654",
"0.48649",
"0.48622224",
"0.48588207",
"0.48523855",
"0.4843724",
"0.4840554",
"0.48382458",
"0.4837486",
"0.48330778",
"0.48318204",
"0.48263317",
"0.48224786",
"0.48219457",
"0.4815109"
] |
0.75187016
|
0
|
Test the addition of a node to itself as a child
|
def test_add_node_to_self_as_child
root = Tree::TreeNode.new("root")
# Lets check the direct parentage scenario
assert_raise(ArgumentError) {root << root}
# And now a scenario where the node addition is done down the hierarchy
# @todo This scenario is not yet fixed.
child = Tree::TreeNode.new("child")
root << child << root
# puts root # This will throw a stack trace
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def just_add_child(node)\n return if @children.member?(node)\n @children << node\n node.parent = self\n update_boxes \n end",
"def add(child); end",
"def child_node; end",
"def test_add\n assert(!@root.has_children?, \"Should not have any children\")\n\n assert_equal(1, @root.size, \"Should have 1 node (the root)\")\n @root.add(@child1)\n\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root << @child3 << @child4\n\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert_equal(2, @child3.size, \"Should have two nodes\")\n\n # Test the addition of a duplicate node (duplicate being defined as a node with the same name).\n assert_raise(RuntimeError) { @root.add(Tree::TreeNode.new(@child1.name)) }\n\n # Test the addition of a nil node.\n assert_raise(ArgumentError) { @root.add(nil) }\n end",
"def valid_child(le)\n\t\t\treturn false\n\t\tend",
"def add_child(node_or_tags); end",
"def add_child(node_or_tags); end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def child_of?(parent); end",
"def child_node=(_); end",
"def add_child(new_child)\n if !@children.include?(new_child)\n new_child.parent = self\n end\n \n end",
"def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end",
"def add_child(child_node) \n child_node.parent = self \n end",
"def add_child(node)\n unless node.respond_to?(:dependencies) && node.respond_to?(:run_list)\n raise Souffle::Exceptions::InvalidChild,\n \"Child must act as a Souffle::Node\"\n end\n unless @children.include? node\n node.parents << self\n @children.push(node)\n end\n end",
"def test_add\n @root.add @left_child1\n assert(!@left_child1.is_root?, \"Left child1 cannot be a root after addition to the ROOT node\")\n\n assert_same(@left_child1, @root.left_child, \"The left node should be left_child1\")\n assert_same(@left_child1, @root.first_child, \"The first node should be left_child1\")\n\n @root.add @right_child1\n assert(!@right_child1.is_root?, \"Right child1 cannot be a root after addition to the ROOT node\")\n\n assert_same(@right_child1, @root.right_child, \"The right node should be right_child1\")\n assert_same(@right_child1, @root.last_child, \"The first node should be right_child1\")\n\n assert_raise ArgumentError do\n @root.add Tree::BinaryTreeNode.new(\"The third child!\")\n end\n\n assert_raise ArgumentError do\n @root << Tree::BinaryTreeNode.new(\"The third child!\")\n end\n end",
"def invalid_child?(child)\n false\n end",
"def invalid_child?(child)\n false\n end",
"def invalid_child?(child)\n false\n end",
"def nested_child?\n @elements.last.class.method_defined?('add_element') && @elements.last.container\n end",
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def add_child_node_and_reparent_attrs(node); end",
"def add_child_node_and_reparent_attrs(node); end",
"def node(node)\n true\n end",
"def add_child(parent, required, name)\n old_num_children = parent.children.length\n if required\n parent.must_have name\n else\n parent.may_have name\n end\n assert_equal old_num_children+1, parent.children.length\n # Here we presume that the child got added to the end of the children.\n child = parent.children.last\n assert_equal name.to_s, child.name\n assert_equal parent, child.parent\n assert child.children.empty?\n if required\n assert child.required? \n else\n assert ! child.required?\n end\n child\n end",
"def add_child(node)\n node.build\n nodes << node\n end",
"def add_child(child)\n # Add an existing subtree to the root node.\n @children << child\n child.parent = self\n #t0 = Time.now\n #propagate(child,:add)\n #puts \" Propagate Timer: #{Time.now - t0} s\"\n child\n end",
"def add_node(node); end",
"def add_child(node) \n @children[node.node_name]=node\n node.parent = self\n # Trick stolen from OpenStruct\n meta = class << self; self; end\n meta.send(:define_method, node.node_name.to_s.to_sym) {@children[node.node_name]}\n end",
"def insert_child\n insert_node('insert_child')\n end",
"def node_can_have_children!(node)\n unless node.children\n node.children = []\n self.node_changes = node\n end\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def add_node( node )\n super( node )\n __add_node__( node )\n end",
"def try_add_child(node, unique_context_constraints)\n unless unique_context_constraints.empty? &&\n (!protocol? || node.protocol_requirement?)\n return false\n end\n\n add_child(node)\n true\n end",
"def test_insert_returns_1_when_2_nodes_added\n @tree.insert(\"b\")\n return_value = @tree.insert(\"a\")\n assert_equal 1, return_value\n end",
"def child?\n true\n end",
"def child?\n !root?\n end",
"def nested_child?\n @options.last.last.class.method_defined?('add_element') && @options.last.last.container\n end",
"def add_child(child)\n @children << child unless @children.include?(child)\n end",
"def has_child(name)\n @hasChild = name\n end",
"def has_child?\n !@children.empty?\n end",
"def child?\n !root?\n end",
"def child?\n false\n end",
"def add_child(child)\n n = root? ? @nodes : @root.nodes\n n << child\n @children << child\n child\n end",
"def test_add_at_specific_position\n assert(!@root.has_children?, \"Should not have any children\")\n\n assert_equal(1, @root.size, \"Should have 1 node (the root)\")\n @root.add(@child1) # First Child added at position 0\n # Validate that children = [@child1]\n assert_equal(@child1, @root[0])\n\n @root << @child2 # Second child appended at position 1.\n # Validate that children = [@child1, @child2]\n assert_equal(@child1, @root[0])\n assert_equal(@child2, @root[1])\n assert_equal(2, @root.children.size, \"Should have two child nodes\")\n\n @root.add(@child3, 1) # Third child inserted at position 1 (before @child2)\n # Validate that children = [@child1, @child3, @child2]\n assert_equal(@child1, @root[0])\n assert_equal(@child3, @root[1])\n assert_equal(@child2, @root[2])\n assert_equal(3, @root.children.size, \"Should have three child nodes\")\n\n @root.add(@child4, @root.children.size) # Fourth child inserted at the end (equivalent to plain #add(child4)\n # Validate that children = [@child1, @child3, @child2, @child4]\n assert_equal(@child1, @root[0])\n assert_equal(@child3, @root[1])\n assert_equal(@child2, @root[2])\n assert_equal(@child4, @root[3])\n assert_equal(4, @root.children.size, \"Should have four child nodes\")\n\n # Now, a negative test. We are preventing addition to a position that does not exist.\n assert_raise(RuntimeError) {\n @root.add(@child5, @root.children.size + 1) # Fifth child inserted beyond the last position that is valid (at 5th pos).\n }\n # Validate that we still have children = [@child1, @child3, @child2, @child4]\n assert_equal(@child1, @root[0])\n assert_equal(@child3, @root[1])\n assert_equal(@child2, @root[2])\n assert_equal(@child4, @root[3])\n assert_nil(@root[4])\n assert_equal(4, @root.children.size, \"Should have four child nodes\")\n\n # Another negative test. Lets attempt to add from the end at a position that is not available\n assert_raise(RuntimeError) {\n @root.add(@child5, -(@root.children.size+2)) # Fifth child inserted beyond the first position that is valid; i.e. at -6\n }\n assert_nil(@root[-5])\n assert_equal(@child1, @root[-4])\n assert_equal(@child3, @root[-3])\n assert_equal(@child2, @root[-2])\n assert_equal(@child4, @root[-1])\n assert_equal(4, @root.children.size, \"Should have four child nodes\")\n\n # Lets correctly add the fifth child from the end to effectively prepend the node.\n @root.add(@child5, -(@root.children.size+1)) # Fifth child inserted beyond the first position; i.e. at -5\n assert_nil(@root[-6])\n assert_equal(@child5, @root[-5])\n assert_equal(@child1, @root[-4])\n assert_equal(@child3, @root[-3])\n assert_equal(@child2, @root[-2])\n assert_equal(@child4, @root[-1])\n assert_equal(5, @root.children.size, \"Should have five child nodes\")\n end",
"def add_child(child)\n if child.is_a? Activity\n return child.set_parent(self)\n else \n puts \"Child not added: child must be an activity\"\n return false\n end\n end",
"def add_child(child_node)\n child_node.parent = self \n end",
"def add_child(node)\n node.added = Date.today if node.is_a? Entry\n super\n end",
"def test_append_additional_node\n list = LinkedList.new\n\n list.append(\"Rhodes\", {\"pounds of food\" => 200})\n list.append(\"Hardy\", {\"pounds of food\" => 200})\n\n assert_instance_of Node, list.head.next_node\n end",
"def add_child(child)\n if child.is_a? Activity\n if self.rep_parent.nil?\n return child.set_parent(self)\n else\n return child.set_parent(self.rep_parent)\n end\n else \n puts \"Child not added: child must be an activity\"\n return false\n end\n end",
"def add_child(child_node)\n child_node.parent = self\n @children << child_node unless @children.include?(child_node)\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def process_child_nodes(node); end",
"def add_child(root, child)\n raise NotImplementedError\n end",
"def is_child?\n !is_parent?\n end",
"def add_to_tree(item, node)\n return rebalance(super(item, node))\n end",
"def add_child(child_node)\n self.children[child_node.char] = child_node\n end",
"def child(node, type=\"a\")\n\t return \"Error. node's can only be of type Node\" unless node.is_a? Node\n\t self.child_a = node if type === \"a\"\n\t self.child_b = node if type === \"b\"\n\tend",
"def add?(value)\n node = TreeNode.new(value)\n added = if root.nil?\n @root = node\n else\n @root.add(node)\n end\n if added\n @length += 1\n self\n else\n nil\n end\n end",
"def add_child(key, child) \n raise \"Leaf nodes don't accept children (request was: #{key.inspect} => #{child.inspect})\"\n end",
"def add_child(child)\n \t\t@children << child\n \tend",
"def each_child\n return nil unless self.child\n node = self.child\n while node\n yield node\n node = node.next_sibling\n end\n return true\n end",
"def add_child(b)\r\n return unless b\r\n a = @nodes[b.name]\r\n if !a\r\n @nodes[b.name] = b\r\n elsif a.kind_of?(VFSGroup)\r\n # Node is already present, merge children\r\n b.nodes.each_value do |n|\r\n a.add_child(n)\r\n end\r\n end\r\n end",
"def add_child(child_node)\n child_node.parent = self\n end",
"def add_child(child_node)\n child_node.parent = self\n end",
"def allowed_type?(parent_node); end",
"def test_add_second_node_to_left\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n assert tree.root.left_node\n end",
"def test_insert_adds_node_at_root\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.root.value\n end",
"def test_single_node_becomes_leaf\n setup_test_tree\n\n leafs = @root.each_leaf\n parents = leafs.collect {|leaf| leaf.parent }\n leafs.each {|leaf| leaf.remove_from_parent!}\n parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}\n\n end",
"def new_child\n nil\n end",
"def insert_after(child1, child2); end",
"def is_node?(obj)\n obj.respond_to?(:children) && obj.location.expression\n end",
"def test_lt2 # Test the << method\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n assert_not_nil(@root['Child1'], \"Child 1 should have been added to Root\")\n assert_not_nil(@root['Child2'], \"Child 2 should have been added to Root\")\n assert_not_nil(@root['Child3'], \"Child 3 should have been added to Root\")\n assert_not_nil(@child3['Child4'], \"Child 4 should have been added to Child3\")\n end",
"def insert_before(child1, child2); end",
"def is_only_child?\n return false if parent.nil? # root\n 1 == parent.children.size\n end",
"def second_child\n child 1\n end",
"def test_it_exists\n assert_instance_of Node, @node\n end",
"def test_hc_nodeappendchildchildexists\n doc = nil\n elementList = nil\n childList = nil\n childNode = nil\n newChild = nil\n memberNode = nil\n memberName = nil\n refreshedActual = []\n \n actual = []\n \n nodeType = nil\n expected = []\n expected << \"strong\"\n expected << \"code\"\n expected << \"sup\"\n expected << \"var\"\n expected << \"acronym\"\n expected << \"em\"\n \n appendedChild = nil\n doc = load_document(\"hc_staff\", true)\n elementList = doc.getElementsByTagName(\"p\")\n childNode = elementList.item(1)\n childList = childNode.getElementsByTagName(\"*\")\n newChild = childList.item(0)\n appendedChild = childNode.appendChild(newChild)\n indexid3799224 = 0\n while (indexid3799224 < childList.length)\n memberNode = childList.item(indexid3799224)\n memberName = memberNode.nodeName()\n actual << memberName\n indexid3799224 += 1\n end\n assertEqualsAutoCase(\"element\", \"liveByTagName\", expected, actual)\n childList = childNode.childNodes()\n indexid3799263 = 0\n while (indexid3799263 < childList.length)\n memberNode = childList.item(indexid3799263)\n nodeType = memberNode.nodeType()\n \n if (equals(1, nodeType))\n memberName = memberNode.nodeName()\n refreshedActual << memberName\n \n end\n indexid3799263 += 1\n end\n assertEqualsAutoCase(\"element\", \"refreshedChildNodes\", expected, refreshedActual)\n \n end",
"def addNodeChild node, name\n\t\tif @root != nil\n\t\t if !node.leftChild\n\t\t \tnode.leftChild = Node.new name\n\t\t \treturn node.leftChild\n\t\t end\n\n\t\t if !node.rightChild\n\t\t \tnode.rightChild = Node.new name\n\t\t \treturn node.rightChild\n\t\t end\n\t\tend\n\tend",
"def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def child_add(child)\n @children.push(child)\n end",
"def test_first_child\n setup_test_tree\n\n assert_equal(@child1, @root.first_child, \"Root's first child is Child1\")\n assert_nil(@child1.first_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.first_child, \"Child3's first child is Child4\")\n end",
"def assert_leaf(node)\n assert node.element_children.empty?, 'expected no children', node\n end",
"def test_add_second_node_to_right\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(60, \"movie b\")\n assert tree.root.right_node\n end",
"def test_has_content_eh\n a_node = Tree::TreeNode.new(\"A Node\")\n assert_nil(a_node.content , \"The node should not have content\")\n assert(!a_node.has_content? , \"The node should not have content\")\n\n a_node.content = \"Something\"\n assert_not_nil(a_node.content, \"The node should now have content\")\n assert(a_node.has_content?, \"The node should now have content\")\n end",
"def has_children?\n @nodes && !@nodes.empty?\n end",
"def add_child(base_node, wordArray, word)\n letter = wordArray.shift()\n if (letter)\n base_node.words << word\n if (base_node.childrens.key?(letter))\n add_child(base_node.childrens[letter], wordArray, word)\n else\n base_node.add_children(letter)\n add_child(base_node.childrens[letter], wordArray, word)\n end\n else\n base_node.final = true\n return\n end\n end",
"def right_child?(node_id)\n (node_id & 1) == 1 # node_id % 2 == 1\n end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def add_child(child)\n child.parent = self\n end",
"def test_return_method_truthy\n @tree.insert(\"a\")\n @tree.insert(\"c\")\n assert_equal true, @tree.includes?(\"c\")\n end",
"def has_children?\n false\n end",
"def add_child(le, cc=nil, &block)\n\t\t\tif valid_child(le)\n\t\t\t\t@children << le\n\t\t\t\tle.parent = self\n\t\t\telse\n\t\t\t\tif !block.nil?\n\t\t\t\t\tblock.call(le)\n\t\t\t\telsif cc.nil?\n\t\t\t\t $stderr << \"invalid child '#{le.tag}' for '#{self.tag}'\"\n\t\t\t \t\traise InternalError.new(\"invalid child '#{le.tag}' for '#{self.tag}'\")\n\t\t\t\telsif le.leftmost_token.nil? && le.rightmost_token.nil?\n\t\t\t\t $stderr << \"invalid child '#{le.tag}' for '#{self.tag}'\"\n\t\t\t \t\traise InternalError.new(\"invalid child '#{le.tag}' for '#{self.tag}'\")\n\t\t\t \telse\n\t\t\t \t if le.leftmost_token.nil?\n\t\t\t\t\t cc.eh.error UnexpectedLE.new(cc, le.rightmost_token, le, self)\n\t\t\t\t\telse\n cc.eh.error UnexpectedLE.new(cc, le.leftmost_token, le , self)\n end\n\t\t\t \tend\n\t\t\tend\n\t\tend",
"def leaf?; false end",
"def children_exist?\n\tend",
"def has_children?\n !leaf?\n end",
"def left_child(node_id)\n node_id << 1 # node_id * 2\n end"
] |
[
"0.74029994",
"0.72090757",
"0.69931376",
"0.69070613",
"0.686713",
"0.6851359",
"0.6851359",
"0.6785406",
"0.67298084",
"0.6728562",
"0.6685328",
"0.6662659",
"0.6607456",
"0.65953904",
"0.6593382",
"0.65564173",
"0.65564173",
"0.65564173",
"0.652232",
"0.6496561",
"0.6473206",
"0.6473206",
"0.6467226",
"0.6467226",
"0.64638454",
"0.6448002",
"0.6436888",
"0.6426737",
"0.6423983",
"0.6414203",
"0.64039606",
"0.6403139",
"0.64014816",
"0.63765854",
"0.63759094",
"0.63582164",
"0.63457185",
"0.63455504",
"0.63451856",
"0.63436764",
"0.63335884",
"0.6328416",
"0.63277334",
"0.63180727",
"0.6313652",
"0.63116693",
"0.63005763",
"0.6295994",
"0.6285566",
"0.62797934",
"0.62709564",
"0.6268885",
"0.62581956",
"0.6256763",
"0.6233349",
"0.6229341",
"0.62212116",
"0.62007725",
"0.6191115",
"0.61678594",
"0.61567044",
"0.61445475",
"0.613215",
"0.6130126",
"0.61281437",
"0.6114111",
"0.6114111",
"0.6111764",
"0.6106618",
"0.6096493",
"0.60926086",
"0.60921466",
"0.60907364",
"0.60836226",
"0.60609084",
"0.605507",
"0.60545117",
"0.6050333",
"0.6049278",
"0.6017957",
"0.60170203",
"0.6016489",
"0.601631",
"0.600523",
"0.59965456",
"0.59954333",
"0.5982162",
"0.59809047",
"0.5978187",
"0.5973659",
"0.5971366",
"0.59656394",
"0.5964501",
"0.59627885",
"0.5961265",
"0.595616",
"0.5947693",
"0.5946081",
"0.5944976",
"0.59389466"
] |
0.74339324
|
0
|
Test whether the tree_leaf method works correctly
|
def test_single_node_becomes_leaf
setup_test_tree
leafs = @root.each_leaf
parents = leafs.collect {|leaf| leaf.parent }
leafs.each {|leaf| leaf.remove_from_parent!}
parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_leaf\n true\n end",
"def is_leaf\n true\n end",
"def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end",
"def is_leaf\n return @left == nil\n end",
"def leaf?\n true\n end",
"def leaf?; false end",
"def leaf?; @leaf; end",
"def is_leaf?\n self.left_child == nil and\n self.right_child == nil\n end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def leaf?\n !node?\n end",
"def is_a_leaf?\n self.left_child.nil? && self.right_child.nil?\n end",
"def leaf?\n right - left == 1\n end",
"def leaf_node?(node_id)\n @leaf_count < node_id\n end",
"def is_leaf?\n self.children_count.zero?\n end",
"def children_are_leaves?\n unless leaf?\n @children[0].leaf?\n end\n end",
"def assert_leaf(node)\n assert node.element_children.empty?, 'expected no children', node\n end",
"def leaf?\n children.empty?\n end",
"def leaf?\n level.zero?\n end",
"def leaf?\n self.children.size == 0\n end",
"def leaf?\n @children.length.zero?\n end",
"def leaf?\n @children.empty?\n end",
"def leaf?(r)\n r.children.empty?\n end",
"def leaf?\n persisted? && right.to_i - left.to_i == 1\n end",
"def leaf_node?(tree_node)\n tree_node.left.nil? && tree_node.right.nil?\nend",
"def leaf?\n leaves.count == 0\n end",
"def has_children?\n !leaf?\n end",
"def leaf?\n record.persisted? && if children.loaded? || tree.columns.counter_cache?\n # no SQL-queries here\n children.empty?\n else\n !children.exists?\n end\n end",
"def leaf?\n @succ.length == 0\n end",
"def leaf?\n new_record? || (rgt - lft == 1)\n end",
"def valid_tree?\n false\n end",
"def valid_tree?\n true\n end",
"def valid_tree?\n true\n end",
"def leaf?\n left.nil? && right.nil?\n end",
"def is_leaf?\n\t\tself.part_map.empty?\n\tend",
"def test_leaves_works\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(40, \"movie b\")\n tree.insert(60, \"movie c\")\n tree.insert(45, \"movie d\")\n tree.insert(20, \"movie e\")\n tree.insert(55, \"movie f\")\n tree.insert(80, \"movie g\")\n assert_equal 4, tree.leaves\n end",
"def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end",
"def valid_tree?\n true\n end",
"def leaf(node, tag)\r\n end",
"def leaf?(node)\n terminal?(node) && out_degree(node) == 0\n end",
"def leaf?\n children.where(parent_id: self.id).empty?\n end",
"def is_subtree(root)\n\nend",
"def is_valid_tree(tree)\n\nend",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def leaf?\n persisted? && if children_counter_cache_column\n self[children_counter_cache_column] == 0\n else\n children.count == 0\n end\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert(!@child1.is_only_child?, \"Child1 is not the only child\")\n assert(!@child2.is_only_child?, \"Child2 is not the only child\")\n assert(!@child3.is_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def _leaf(name, rx, ignorable: false, boundary: false, tests: [], preconditions: [], process: nil)\n raise Error, 'tests must be an array' unless tests.is_a? Array\n raise Error, 'preconditions must be an array' unless preconditions.is_a? Array\n\n init\n init_check(name)\n name = name.to_sym\n return if dup_check(:leaf, name, rx, tests + preconditions)\n\n tests << [process] if process\n @leaves << Leaf.new(name, rx, ignorable: ignorable, boundary: boundary, tests: tests, preconditions: preconditions)\n end",
"def leaf?(sexp)\n list?(sexp) && depth(sexp) == 1\nend",
"def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end",
"def leaf?(term_or_go)\n go_id = as_term(term_or_go).id\n not_a_leaf = @terms.any? do |term| \n term.is_as.any? do |is_a_id| \n go_id == is_a_id\n end\n end\n !not_a_leaf\n end",
"def leaf_node?(index)\n return index >= @heap_size/2\n end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end",
"def add_leaf(leaf, defer_update = false)\n raise \"node is not lowest level and can therefore not get a leaf: #{self}\" unless lowest_level?\n children.insert(children.find_index {|child| child.shash > leaf.shash} || -1, leaf) #insertion_sort here\n leaf.parent = self\n divide_if_needed(defer_update)\n end",
"def leaf_version?\n\t\treturn self.child_versions.empty?\n\tend",
"def invalid_leaf?\n if valid_flag\n errors.add(:valid_flag, '契約中のリーフは削除できません。')\n return false\n end\n end",
"def find_leaf\n if first_question.descendants.length > 0\n leaves = first_question.descendants.select {|q| q.leaf?}\n\n raise StandardError, \"Multiple leaves found!\" if leaves.length > 1\n raise StandardError, \"No leaf found!\" if leaves.length == 0\n\n leaves.first\n else\n # Only one question!\n first_question\n end\n\n end",
"def has_children?(tree_node)\n tree_node.left || tree_node.right\n end",
"def test_root\n setup_test_tree\n\n # TODO: Should probably change this logic. Root's root should\n # return nil so that the possibility of a recursive error does not exist\n # at all.\n assert_same(@root , @root.root, \"Root's root is self\")\n assert_same(@root , @child1.root, \"Root should be ROOT\")\n assert_same(@root , @child4.root, \"Root should be ROOT\")\n assert_equal(2 , @root.node_height, \"Root's height after adding the children should be 2\")\n end",
"def create_leaf(path, data)\n return @create_leaf_override.call(self, data) if @create_leaf_override\n return data.to_s.strip\n end",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def test_return_method_truthy\n @tree.insert(\"a\")\n @tree.insert(\"c\")\n assert_equal true, @tree.includes?(\"c\")\n end",
"def new_leaf(payload, **kwargs)\n factory.leaf_node(payload, **kwargs)\n end",
"def leaf_node?(indx)\n return indx >= @heap_size/2\n end",
"def test_save_tree\n end",
"def test_insert_returns_depth_0_if_just_root\n return_value = @tree.insert(\"a\")\n assert_equal 0, return_value\n end",
"def test_return_method_falsey\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal true, @tree.includes?(\"c\")\n end",
"def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibling?, \"Child3's last sibling is itself\")\n assert( @child4.is_last_sibling?, \"Child4's last sibling is itself\")\n end",
"def verify\n 1.upto(@leaf_count - 1) do |node|\n next if @nodes[node] ==\n HashTree.node_hash(node, @nodes[HashTree.left_child(node)],\n @nodes[HashTree.right_child(node)])\n raise \"Tree integrity verification failed\" \n end\n self\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def sub_branch?\n !root?\n end",
"def test_tree_representation\n e =\n'ROOT (0.94)\n outlook => rainy (0.694)\n windy => TRUE (0.0)\n play => no (0.0)\n windy => FALSE (0.0)\n play => yes (0.0)\n outlook => overcast (0.694)\n play => yes (0.0)\n outlook => sunny (0.694)\n humidity => normal (0.0)\n play => yes (0.0)\n humidity => high (0.0)\n play => no (0.0)\n'\n assert_equal e, @tree.to_s\n end",
"def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_first_sibling?, \"Child3 is not the first sibling\")\n assert( @child4.is_first_sibling?, \"Child4's first sibling is itself\")\n end",
"def assign_leaf(node)\n if node.left && node.right\n @leaf_parent = node\n @replacer_leaf = node.right\n assign_leaf(node.left)\n assign_leaf(node.right)\n else\n return\n end\n end",
"def leaf_count\n @leaf_count\n end",
"def empty?\n @root.empty? && @root.leaf?\n end",
"def test_add_node_to_self_as_child\n root = Tree::TreeNode.new(\"root\")\n\n # Lets check the direct parentage scenario\n assert_raise(ArgumentError) {root << root}\n\n # And now a scenario where the node addition is done down the hierarchy\n # @todo This scenario is not yet fixed.\n child = Tree::TreeNode.new(\"child\")\n root << child << root\n # puts root # This will throw a stack trace\n end",
"def test_node_starts_with_empty_branches\n node = Node.new(50, \"movie a\")\n refute node.left_node\n refute node.right_node\n end",
"def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end",
"def propagation_leafs\n trace.each_vertex.find_all { |v| trace.leaf?(v) }\n end",
"def tree_nodes_valid?\n (root_tree_node.present? || top_nav_node_info_cd.zero?) &&\n (branch_tree_node.present? || sub_nav_node_info_cd.zero?) &&\n (leaf_tree_node.present? || trd_nav_node_info_cd.zero?)\n end",
"def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end",
"def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end",
"def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right_leaves = count_leaf_nodes(node.right_child)\n return left_leaves + right_leaves\n end\nend",
"def test_first_child\n setup_test_tree\n\n assert_equal(@child1, @root.first_child, \"Root's first child is Child1\")\n assert_nil(@child1.first_child, \"Child1 does not have any children\")\n assert_equal(@child4, @child3.first_child, \"Child3's first child is Child4\")\n end",
"def test_add_third_node_to_left\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n movie_c = tree.insert(30, \"movie c\")\n assert_equal 2, tree.root.left_node.left_node.depth\n end",
"def is_balanced_binary_tree?(root)\n is_balanced_rec(root) != -1\nend",
"def test_return_array_root_node\n @tree.insert(\"f\")\n assert_equal [\"f\"], @tree.sort\n end",
"def left_child?(node_id)\n (node_id & 1) == 0 # node_id % 2 == 0\n end",
"def test_min_root_only_node\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.min\n end",
"def leaf?\n (keys - [:name, :balance]).empty?\n end",
"def leaf?\n self.variations.size == 0\n end",
"def test_add\n tree = BinTree.new\n #test empty\n assert tree.root == nil\n\n test_node = TreeNode.new(6)\n tree.add(test_node)\n #test one node added\n assert_equal(tree.root, test_node)\n\n test_node = TreeNode.new(4)\n tree.add(test_node)\n #test 2 nodes added\n assert_equal(test_node, tree.root.left)\n\n test_node = TreeNode.new(9)\n tree.add(test_node)\n #test 3 nodes added\n assert_equal(test_node, tree.root.right)\n\n test_node = TreeNode.new(-1)\n tree.add(test_node)\n #test 4 nodes added\n assert_equal(test_node, tree.root.left.left)\n end",
"def leaves\n descendants.where(arel_table[is_leaf_column_name].eq(true))\n end",
"def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end",
"def test_insert_returns_1_when_2_nodes_added\n @tree.insert(\"b\")\n return_value = @tree.insert(\"a\")\n assert_equal 1, return_value\n end",
"def touch?( other )\n\t\tcommon_leaves = [ ]\n\t\tother.leaves.each do |leaf|\n\t\t\t@leaves.include?(leaf) and common_leaves << leaf\n\t\tend\n\t\tif common_leaves.size > 0\n\t\t\tcommon_leaves.first\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def lowest_level?\n !children.any? {|child| child.kind_of?(NonLeafNode)}\n end",
"def test_first_node_is_root_node\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n assert_equal \"movie a\", tree.root.title\n end",
"def test_add_second_node_to_left\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n assert tree.root.left_node\n end"
] |
[
"0.84353673",
"0.84353673",
"0.83431554",
"0.8100705",
"0.806321",
"0.7953672",
"0.7895372",
"0.77505195",
"0.76434004",
"0.7642754",
"0.7638584",
"0.7498978",
"0.73904014",
"0.7389269",
"0.73611826",
"0.7336549",
"0.7325284",
"0.73150194",
"0.72899014",
"0.72705096",
"0.72587913",
"0.72562987",
"0.7252391",
"0.72521484",
"0.7213666",
"0.71466047",
"0.7133827",
"0.71067095",
"0.7073697",
"0.70618904",
"0.7050752",
"0.7050752",
"0.700482",
"0.6983857",
"0.69220084",
"0.691388",
"0.68586797",
"0.6848545",
"0.6798064",
"0.678856",
"0.6784741",
"0.67662746",
"0.671465",
"0.6708376",
"0.6680022",
"0.66690826",
"0.66360074",
"0.65968484",
"0.65740764",
"0.652698",
"0.6508925",
"0.6496686",
"0.6493969",
"0.64399695",
"0.64330965",
"0.6418993",
"0.6412344",
"0.6407995",
"0.6399237",
"0.63520896",
"0.633586",
"0.6333739",
"0.63302255",
"0.63266164",
"0.63230103",
"0.6288482",
"0.62811744",
"0.62718594",
"0.62710613",
"0.6269101",
"0.6245582",
"0.6206535",
"0.61972976",
"0.61956805",
"0.6173334",
"0.6160759",
"0.61546683",
"0.6134978",
"0.61283034",
"0.61065197",
"0.6091853",
"0.60773957",
"0.60709035",
"0.6060773",
"0.60573566",
"0.6035638",
"0.6033992",
"0.6027144",
"0.60269225",
"0.6018755",
"0.6016444",
"0.60143363",
"0.6010848",
"0.60021424",
"0.6000855",
"0.5997109",
"0.59882075",
"0.59864986",
"0.59763896",
"0.5970778"
] |
0.7808975
|
7
|
Second, implement the highest_prime_number_under method below. It should accept a number as an argument and return the highest prime number under that number. For example, the highest prime number under 10 is 7.
|
def highest_prime_number_under(number)
prime = number - 1
counter = 1
until is_prime?(prime)
prime -= 1
end
return prime
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def highest_prime_number_under(number)\n start = number - 1\n start.downto(1) do |num|\n if is_prime?(num)\n return num\n end\n end\n end",
"def highest_prime_number_under(number)\n\nend",
"def highest_prime_number_under(number)\n until is_prime?(number)\n number -= 1\n end\n number\nend",
"def highest_prime_number_under(number)\n highest_prime = 0\n for num in 1..number\n if is_prime?(num) && num > highest_prime\n highest_prime = num\n end\n end\n return highest_prime\nend",
"def highest_prime_number_under(number)\n highest_prime_number_under = 0\n ary = (number-1).downto(2).to_a\n ary.each do |x|\n counter = 0 \n (2..(x-1)).each do |num|\n if ( x % num ) == 0\n counter += 1\n else\n counter = counter\n end \n end \n \n if counter > 0 \n highest_prime_number_under = 0\n else \n highest_prime_number_under = x\n p \"The highest prime number under #{number} is \" + x.to_s\n break\n end\n end \nend",
"def highest_prime_number_under(number)\n counter = number\n number.times do\n if is_prime?(counter)\n p counter\n break\n else\n counter -= 1\n end\n end\nend",
"def highest_prime_number_under(number)\n\t\tprimes = []\n\t\t2.upto(number).each do |x|\n\t\t\tif is_prime?(x) && x < number\n\t\t\t\tprimes << x\n\t\t\tend\n\t\tend\n\t\tprimes.max\n\tend",
"def largest_prime_number(upper)\n answer = 2\n point = 3\n divisor = upper\n\n divisor /= 2 while divisor.even?\n\n while divisor != 1\n while (divisor % point) == 0\n answer = point\n divisor /= point\n end\n point += 2\n end\n answer\nend",
"def largest_prime(number)\r\n limit = Math.sqrt(number).floor \r\n (2..limit).select { |n| number % n == 0 && Prime.prime?(n) }.max\r\nend",
"def largest_prime_factor(num)\n num.downto(1) do |n|\n if num % n == 0 && prime?(n)\n return n\n end\n end\nend",
"def largest_prime_factor(num)\n num.downto(2) do |i|\n return i if (num % i).zero? && prime(i)\n end\nend",
"def largest_prime_factor(num) \n num.downto(2).each do |factor|\n if num % factor == 0 && isPrime(factor)\n return factor\n end\n end\nend",
"def get_largest_prime_factor num\n get_largest_number(prime_factor_numbers(num))\nend",
"def highest_prime_of(factors)\n factors.each do |factor|\n if check_prime(factor)\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n track = 0\n (num).downto(2).each do |factor|\n \n if num % factor == 0 && prime?(factor)\n return factor\n end\n end\n \nend",
"def largest_prime_factor(num)\n return num if prime?(num)\n\n prime_factors(num).max\nend",
"def largest_prime_factor(num)\n (2..num).reverse_each do |factor|\n if (num % factor == 0 && Prime.prime?(factor))\n return factor\n end\n end\nend",
"def largest_prime_factor (num)\n largest = 1\n (2..num).each do |ele|\n if num % ele == 0 && prime?(ele) && largest < ele\n largest = ele\n end\n end\n return largest\nend",
"def largest_prime_factor(num)\n factors = (1..num).select { |factor| num % factor == 0}\n large_prime = factors.reverse.select { |i| return i if prime?(i)}\nend",
"def largest_prime_factor(number)\n factor = 1\n\n while factor <= number\n if number % factor == 0\n return number / factor if is_prime?(number / factor)\n end\n factor += 1\n end\nend",
"def find_primes_under(num)\n\tprimes = [2]\n\tcounter = 3\n\twhile primes[-1] < num\n\t\tcounter2 = 2\n\t\twhile counter2 <= counter\n\t\t\tif counter % counter2 == 0\n\t\t\t\tbreak\n\t\t\telsif\n\t\t\t\tcounter2 * counter2 > counter\n\t\t\t\tprimes << counter\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tcounter2 += 1\n\t\tend\n\tcounter += 1\n\tend\n\tprimes[0..-2]\nend",
"def largest_prime_factor(num)\n i = num - 1\n\n while i > 1 \n if is_prime?(i) && num % i == 0\n return i \n end\n i -= 1\n end\n \n num\nend",
"def largest_prime_factor(num)\n num.downto(1).each do |divisor|\n if num % divisor == 0 && isprime?(divisor)\n return divisor\n end\n end\n return 1\nend",
"def largest_prime(number)\n is_prime = false\n current_num = number\n divisor = 2\n max_prime = 1\n\n while is_prime != true && divisor <= current_num\n if current_num % divisor === 0\n current_num /= divisor\n if divisor > max_prime\n max_prime = divisor\n end\n divisor = 2\n else\n divisor += 1\n end\n\n if divisor > current_num\n is_prime = true\n end\n end\n\n puts max_prime\n return max_prime\nend",
"def largest_prime_factor(number)\n prime = 2\n max = 1\n while (prime <= number)\n if(number % prime == 0)\n max = prime\n number = number/prime\n else\n prime += 1\n end\n end\n max\nend",
"def largest_factor(number)\n result = prime_factors(number).sort\n result[-1]\nend",
"def largest_prime_factor(num)\n (1..num).reverse_each do |factor|\n if num % factor == 0 && prime?(factor)\n return factor\n end\n end\nend",
"def largest_prime_factor( x ) \n require 'mathjb'\n primes = primes_below(x)\n i = 0\n \n until primes.include?(x)\n div = primes[i]\n if x % div == 0 then\n x /= div #if div is a factor of x, set x to x / div\n i = 0\n else\n i += 1\n end\n end\n return x\nend",
"def largest_prime_factor(num)\n largest = num\n variable_num = 2\n\n while variable_num < largest\n while largest % variable_num == 0 && largest != variable_num\n largest = largest / variable_num\n end\n variable_num += 1\n end\n return largest\nend",
"def largest_prime_factor(num)\n i = num - 1\n while i >= 2\n if num % i == 0 && is_prime?(i) == true\n return i\n end\n i -= 1\n end\n num\nend",
"def largest_prime_factor(num)\n num.prime_division.last[0]\n end",
"def largest_prime_factor(num)\n return nil if num <= 1\n (2..num).reverse_each do |n|\n return n if prime?(n) && num%n == 0\n end\nend",
"def largest_prime(num)\n largest_prime = 0\n i = 2\n while i * i <= num\n if num % i == 0\n num /= i\n largest_prime = i\n else\n i += 1\n end\n end\n\n if num > largest_prime\n largest_prime = num\n end\n\n largest_prime\nend",
"def largest_prime_factor num\n divisors = []\n max = 0\n\n (1..num).each { |el| divisors << el if num % el === 0 && isPrime(el)}\n\n max = divisors[0]\n\n divisors.each do |el|\n max = el if el > max \n end\n\n max\nend",
"def largest_prime_factor(number)\n # start with the number and go backwards\n while number > 0\n numb_split = number.to_s.split('')\n numb_split_length = numb_split.length\n #p numb_split[numb_split_length - 1]\n if numb_split[numb_split_length - 1] == \"5\" || numb_split[numb_split_length - 1] == \"0\" \n\n \n elsif number%2 == 0 && number > 2 \n # definitely not prime\n elsif number%2 == 0 && number%3 == 0\n \n \n else\n # test if number is prime\n # if number is prime\n \n\n p number.to_s\n end\n number -= 1 \n end\n\nend",
"def upper_limit_for(desired_prime_number)\n i = 2\n while (i / Math.log(i)) < desired_prime_number do\n i = i + 1\n end\n return i\n end",
"def my_largest_prime(num)\n counter = 2\n until num == 1\n if num % counter == 0\n sol = counter\n num /= counter\n else\n counter += 1\n end\n end\n return sol\nend",
"def largest_prime_factor(num)\n puts \"num = #{num}\"\n Prime.first(num).select {|i| i}\nend",
"def largest_prime_factor(num)\n i = num\n while i > 0\n if num%i == 0 && prime?(i)\n return i\n end\n i -= 1\n end\nend",
"def largest_prime_factor(number)\n # divide by the smallest prime number (2) until\n # number is no longer divisble by the given prime number\n\n # iterate to the next (prime) number\n # divide and repeat\n # the forumula will return the largest prime factor\n\n prime_number = 2\n counter = 0\n\n while prime_number != number\n if number % prime_number == 0\n number /= prime_number\n else\n prime_number += 1\n end\n \n end\n prime_number\nend",
"def largest_prime_factor(number)\n\tlargest_pfactor = number\n\tfactor = 2\n\twhile(factor <= (largest_pfactor / 2)) do\n\t\tif(largest_pfactor % factor == 0)\n\t\t\tlargest_pfactor = largest_pfactor / factor\n\t\telse\n\t\t\tfactor = factor + 1\n\t\tend\n\tend\n\tlargest_pfactor\nend",
"def prime_factors(num)\n factors = num.prime_division\n factors.to_a\n largest_factor = factors[-1][0]\n p largest_factor\nend",
"def largest_prime_factor(num)\n counter = 2\n biggestFactor = 0\n while (counter * counter) <=num\n if num % counter == 0\n num = num / counter\n biggestFactor = counter\n else\n counter+=1\n end\n end\n\n if (num > biggestFactor)\n biggestFactor = num\n end\n biggestFactor\nend",
"def largest_prime_factor(num)\n\n def prime?(num)\n return false if num < 2\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n\n true\n end\n\n if prime?(num)\n return num\n end\n\n (num.downto(2)).each do |i|\n if prime?(i) && num % i == 0\n return i\n end\n end\nend",
"def largest_prime_factor(current_number)\n\tprime_factors = []\n\ti = 2\n\twhile current_number > 1\n\t\twhile current_number % i == 0\n\t\t\tprime_factors << i\n\t\t\tcurrent_number /= i\n\t\tend\n\t\ti += 1\n\tend\n\treturn prime_factors.last\nend",
"def largest_prime_factor(number)\n\tfactors = []\n\n\t(1...number).each do |i| \n\t\tif number % i == 0 && Prime.prime?(i)\n\t\t\tfactors.push(i)\n\t\tend\n\tend\n\tfactors.last\nend",
"def largest_prime_factor_of(num)\n max = num\n test = 3\n best = 1\n\n while (max >= test) do\n if max % test == 0\n best = test\n max = max / test\n else\n test += 2\n end\n end\n best\nend",
"def largest_prime_factor(input)\n\n prime = input\n (2..Math.sqrt(input).to_i).each do |i|\n break if prime <= 1\n prime /= i while (prime > i && prime % i == 0)\n end\n prime\nend",
"def largest_prime_factor(num)\n prime_factors = []\n (2..num).each do |n|\n prime_factors << n if prime?(n) && num % n == 0\n end\n prime_factors[-1]\nend",
"def largest_prime_factor(num)\n big = 0\n prime = 0\n \n return false if num < 2\n\n # num is the only prime\n return num if prime?(num)\n \n # loops in reverse and returns the largest and first divisible prime\n j = num - 1\n while j > 1\n if num % j == 0 && prime?(j)\n return j\n end\n j -= 1\n end\nend",
"def largest_prime_factor(input)\n prime = input\n (2..Math.sqrt(input).to_i).each do |i|\n # Here we use the square root function to cut our range down drastically\n break if prime <= 1\n while (prime > i && prime % i == 0) do\n prime /= i\n puts \"prime - #{prime}, i - #{i}\"\n end\n end\n prime\nend",
"def largestPrimeFactor(num)\n\t(2..num).each do |n|\n\t\treturn num if num <= n\n\t\tnum /= n if (num > n && num % n == 0)\n\tend\nend",
"def find_largest_prime(n)\n while true\n smallest_prime = find_smallest_prime(n)\n if smallest_prime < n\n n /= smallest_prime\n else\n return n\n end\n end\nend",
"def largest_prime_factor(num)\n lnum = nil\n (2..num).each do |factor|\n if num % factor == 0 && prime?(factor)\n lnum = factor\n end\n end\n lnum\nend",
"def largest_prime_factor(num)\n (0..num).reduce { |acc, n| prime?(n) && (num % n).zero? ? n : acc }\nend",
"def largest_prime(int)\n def is_prime?(int)\n div = 2\n until div >= int\n return false if int % div == 0\n div += 1\n end\n true\n end\n remainder = int\n divider = 2\n prime_factors = []\n while divider < remainder\n if remainder % divider == 0 && is_prime?(divider)\n prime_factors << divider\n remainder /= divider\n end\n divider += 1\n end\n prime_factors << remainder\n puts prime_factors\n prime_factors.max\nend",
"def largest_prime_factor\n number = 600851475143\n n = 2\n while n < number\n if number % n == 0\n factor = number / n\n return factor if is_prime?(factor)\n end\n n += 1\n end\nend",
"def largest_prime_factor(num)\n return nil if num < 2\n (1..num).inject do |acc, fact|\n if num % fact == 0 && prime?(fact) && fact >= acc\n fact\n else\n acc\n end\n end\nend",
"def largest_prime_factor(num)\n factors = []\n half_of_num = num / 2\n\n (2..half_of_num).each do |factor|\n if num % factor == 0\n factors << factor\n num = num / factor\n end\n end\n factors.max\nend",
"def largest_prime_factor(num)\n primes = []\n (1..num).each do |n|\n primes << n if num % n == 0 && is_prime?(n)\n end\n primes.max\nend",
"def largest_prime_factor(n)\n recursive_prime_factors(n)\n PRIMES.keys.sort().last\nend",
"def largest_prime_factor(num)\n\ti=2 \n\tquotient = 0\n\twhile(quotient != 1) do\n\t\ti +=1\n\t\tif(is_prime?(i) && (num % i == 0))\n\t\t\tdivisor = quotient == 0 ? num : quotient\n\t\t\tquotient = divisor / i\n\t\tend\t\n\tend\n\treturn i \nend",
"def largest_prime_factor(num)\n factors = []\n\n (1..num).each do |i|\n if num % i == 0\n factors << i \n end\n end\n\n primes = []\n factors.each do |num|\n if is_prime?(num)\n primes << num \n end\n end\n\n primes.max\nend",
"def largest_prime(n)\n i = 2\n largest = 0\n while (i <= n)\n if (n % i == 0)\n while (n % i == 0 )\n n = n / i\n largest = i\n puts \"I am n #{n}\"\n puts \"I am i #{i}\"\n i += 1\n end\n end\n i += 1\n end\n return largest\nend",
"def largest_prime_factor(num)\n divisor = 1\n\n (2..num).each do |i|\n if num % i == 0 && is_prime?(i)\n divisor = i\n end\n end\n\n divisor\nend",
"def largest_prime_factor(num)\n \n (1..num).inject do |largest_factor, factor|\n if num % factor == 0 && prime?(factor)\n largest_factor = factor\n else\n largest_factor\n end\n end\nend",
"def max_prime_factor(num)\n return num if num == 1 || num < 1\n max_num = (num ** 0.5 + 1).to_i\n f = (2..max_num).find { |x| num % x == 0 } || num\n [f, max_prime_factor(num / f)].max\nend",
"def largest_prime(n) #600851475143\r\n p = 0\r\n i = 5\r\n nums = []\r\n while i*i < n\r\n if n % i == 0\r\n nums << i\r\n end\r\n\r\n i += 1\r\n end\r\n\r\n nums.reverse_each do |num|\r\n if prime?(num)\r\n return num\r\n end\r\n end\r\n\r\nend",
"def print_primes(num)\r\n\tlargest_div = 2;\t\t\t\r\n\twhile num > 1\r\n\t\tdiv = 2;\r\n\t\twhile num % div != 0\r\n\t\t\t\tdiv += 1\r\n\t\tend\r\n\t\tnum = num / div\r\n\t\tlargest_div = div\r\n\tend\r\n\treturn largest_div\r\nend",
"def largest_prime_factor(num)\n #prime_division returns an array of 2 element arrays containing prime factorization - [[2, 1], [5, 2]]\n #flat_map contatenates the 2 element arrays into a single array [2, 5, 5]\n array = Prime.prime_division(num).flat_map { |factor, power| [factor] * power }\n\n largest = 0\n array.each do |i|\n if i > largest\n largest = i\n end\n end\n return largest\nend",
"def largest_prime_factor(num)\n divisors = []\n (2..num).each do |divisor|\n if num % divisor == 0\n if prime?(divisor)\n divisors << divisor\n end\n end\n end\n divisors[-1]\nend",
"def largest_prime_factor(n)\n i = 2\n largest = 0\n while i <= n\n if n % i == 0\n while n % i == 0\n n = n / i\n largest = i\n i += 1\n end\n end\n i += 1\n end\n return largest\nend",
"def largest_prime_factor(input)\n lpf = 2\n\n while lpf < input\n\n if input % lpf == 0\n\n input = input / lpf\n lpf = 2\n else\n lpf += 1\n end\n end\n\n return lpf\nend",
"def largest_number (number_1, number_2)\n if (number_1 == number_2)\n return number_1 # could also return number_2 here, doesn't matter which\n elsif (number_1 < number_2)\n return number_2\n elsif (number_1 > number_2)\n return number_1\n end\nend",
"def largestPrime someNumber\n pNumers = Array.new\n i = 2\n while someNumber > 1\n while someNumber % i == 0\n pNumers << i\n someNumber /= i\n end\n i += 1\n end\n puts pNumers.last\nend",
"def greatest_factor(num)\n (2...num).reverse_each { |i| return i if num % i == 0}\nend",
"def getMaxPrime(numb)\n def isPrime(n)\n return false if n <= 1\n 2.upto(Math.sqrt(n).to_i) do |x|\n return false if n%x == 0\n end\n true\n end\n\n primes = []\n (2..10000).each { |x| primes << x if isPrime(x) }\n \n max = 0\n primes.each do |i|\n if numb % i == 0\n max = i\n end\n end\n puts max\nend",
"def largest_pfactor(number)\n i=2\n\n while i<=number\n\n if i==number\n puts number\n elsif number%i == 0\n number=number/i\n puts i\n i=2\n end\n\n if i%2==0\n i+=1\n else\n i+=2\n end\n\n end\n\nend",
"def next_largest_number (array, given_number)\n array.find {|number| number > given_number}\nend",
"def p005(upper_bound = 20)\n # This builds on the idea that any value which is a multiple of another value can be used instead of it\n # Also that the lowest common multiple is a product of the minimal set of prime-multiples that cover the factors\n # So e.g. the lowest common multiple of 1..6 would be 5 x 2 x 2 x 3 = 60, where 2 appears twice because 2 x 2 = 4\n required_factors = (2..upper_bound).to_a\n required_primes = {}\n required_factors.each do |factor|\n required_primes.merge!(Prime.prime_division(factor).to_h) do |_prime_factor, old_multiple, new_multiple|\n [old_multiple, new_multiple].max\n end\n end\n required_primes.reduce(1) { |common_multiple, prime_multiple| common_multiple * prime_multiple[0]**prime_multiple[1] }\nend",
"def find_highest_prime_factor(n)\n # Read http://joezack.com/index.php/2009/01/15/project-euler-problem-3-in-ruby/ - which points out you can\n # stop searching at the square root of a number. Speedup!\n (Math.sqrt(n).ceil).downto 2 do |i|\n if n % i == 0 && find_highest_prime_factor(i) == 1\n return i\n end\n end\n 1\nend",
"def biggest(x,y)\n if x <= y\n return y\n else\n return x\n end\nend",
"def greatest_factor(num)\n\n return num / 2\n\nend",
"def largest_number (number_1, number_2)\n \n [number_1, number_2].max\n \nend",
"def find_largest_num(nums)\n\treturn nums.max()\nend",
"def larget_prime_factor(n)\n temp = n\n largest = 0\n div = 2\n\n while temp >= div * div\n if temp % div == 0\n temp /= div\n else\n div += 1\n end\n end\n\n largest = temp if temp > largest\n return largest\nend",
"def get_primes(upper_bound)\n primes = []\n (2..upper_bound).each do |potential_prime|\n is_prime = true #default to true if the below loop doesn't prove it false\n (2..(potential_prime - 1)).each do |divisor| #we start from 2 because that is the first number\n #that we know is not prime - 1 is there so we don't divide the number by itself because\n #we know that it is possible\n if potential_prime % divisor == 0\n is_prime = false\n break\n end\n end\n\n #HERE - we know if is_prime is true, it must be prime\n if is_prime\n primes << potential_prime #this is how you get all the numbers to the max number\n end\nend\n\n return primes\nend",
"def prime?(integer)\nn = integer\nif n < 1 then raise ArgumentError.new(\"Positive integers only\")\nend\nlargest_factor = nil\nfor i in 2..(n/2)\n\tif (n % i) == 0\n\t\tlargest_factor = i\n\tend\nend\n\nlargest_factor ||= n \nend",
"def upper_bound_for_nth_prime (n)\n return n * (Math.log(n) + Math.log(Math.log(n-1) ) )\n end",
"def largest_prime(num)\n\tresult = []\n\ti = 2\n\twhile i <= num\n\t\tif is_prime?(i)\n\t\t\tif num % i == 0 # Check for whole number if % by i \n\t\t\t\tnum = num / i # Update the num\n\t\t\t\tresult << i # Add i to the array\n\t\t\t\ti = 2 # Reset i to 2\t\n\t\t\tend\t\n\t\tend\n\t\ti += 1\t\n\tend\n\tresult\nend",
"def max_of_two(number1, number2)\n if number1 > number2\n return number1\n else \n return number2\n end\nend",
"def largest_prime_factor(input)\n factors = []\n (1..input).each do |x|\n if input % x == 0\n factors << x\n x += 1\n else\n x == input\n break\n end\n end\nend",
"def largest_prime_factor(n)\n divisor = 2\n while(divisor <= n)\n n%divisor == 0 ? n = n/divisor : divisor += 1\n end\n divisor\nend",
"def largest_int(numbers)\n\tnumbers.sort!\n\tnumbers[-1]\nend",
"def highest_value\n @values.inject { |highest, val| highest = (val < 21 && val > highest) ? val : highest }\n end",
"def find_largest_prime(integer)\n factor_array = []\n potential_factor_array = (2..integer).to_a\n potential_factor_array.each do |factor|\n if integer % factor == 0\n factor_array << factor\n end\n end\n largest_factor = factor_array.last\n potential_factor_array = (2..largest_factor).to_a\n potential_factor_array.each do |potential_factor|\n factor_array.each do |factor|\n if factor != potential_factor && factor % potential_factor == 0\n factor_array.delete(factor)\n end\n end\n end\n p factor_array.last\nend",
"def three num\n max = 0\n acc = 1\n for i in 2..num\n if num % i == 0 #first check if i divides the number\n if isPrime?(i) #then check if it is prime (part of the prime factorization)\n max = i #keep the max so far\n temp = num #this loop is for numbers made up of many of the same prime i.e. 2^32\n while (temp % i == 0)\n temp = temp / i\n acc = acc * i\n if acc == num\n return max\n end\n end\n end\n end\n end\n return max\nend",
"def max_of_two(number1,number2)\n if number1 < number2\n output = number2\n else\n output = number1\n end\n return output\nend",
"def greatest_prime_factor(n)\n return false if n < 1\n divisor = Math.sqrt(n).floor\n\n while divisor>=2\n return divisor if prime?(divisor) && n%divisor==0\n divisor-=1\n end\n return false\nend",
"def largest_prime_factor n\n max_prime = -1\n i = 3\n # check if n is product of 2's. then the max prime is 2. and n will be 1 at the end.\n while n % 2 == 0\n max_prime = 2\n n /= 2\n end\n\n #if n is produc of 3's , then the max prime is 3, and n will be 1 at the end.\n #if n is not product of 3's, it contains other prime factors. these factors must be greater\n #than 3 because we alreay excluded 2's in the previous step. and we have excluded 2's multiples in the\n #previous steps, so only need to check the odd numbers for possible factors.\n while i*i <= n\n while n % i == 0\n max_prime = i\n n /= i\n end\n i += 2\n end\n\n if n > 2\n max_prime = n\n end\n max_prime\nend"
] |
[
"0.84532905",
"0.8345327",
"0.834144",
"0.8112479",
"0.805265",
"0.79949474",
"0.7853941",
"0.76582015",
"0.7296592",
"0.723168",
"0.7223145",
"0.72068954",
"0.71572",
"0.7149735",
"0.71105057",
"0.7074159",
"0.7051469",
"0.7044985",
"0.70053464",
"0.70033205",
"0.6993876",
"0.697685",
"0.69727516",
"0.6960429",
"0.69348323",
"0.69188195",
"0.6912469",
"0.6910534",
"0.69042206",
"0.69013304",
"0.6898013",
"0.68882227",
"0.68847436",
"0.68723905",
"0.68080807",
"0.6803158",
"0.6788098",
"0.6787517",
"0.67600304",
"0.6751595",
"0.6747992",
"0.67424786",
"0.67228615",
"0.67161226",
"0.6711218",
"0.66850305",
"0.6676453",
"0.6660835",
"0.66580653",
"0.6653696",
"0.6638136",
"0.66273886",
"0.6617673",
"0.6616835",
"0.6609597",
"0.6604164",
"0.6581985",
"0.65816957",
"0.65809464",
"0.65730757",
"0.6554853",
"0.6523375",
"0.6521528",
"0.65132636",
"0.65074074",
"0.6501309",
"0.6497232",
"0.64957714",
"0.64781976",
"0.64576864",
"0.6441097",
"0.6439201",
"0.64318484",
"0.6410309",
"0.6406162",
"0.63829386",
"0.6363801",
"0.6361473",
"0.63138354",
"0.6294664",
"0.62618124",
"0.62523973",
"0.6250049",
"0.6240637",
"0.62366796",
"0.62352836",
"0.6224756",
"0.619683",
"0.61851406",
"0.6177209",
"0.61632043",
"0.61627907",
"0.61552876",
"0.6134325",
"0.611462",
"0.61111397",
"0.6110656",
"0.6086101",
"0.60744846",
"0.6073456"
] |
0.8340299
|
3
|
FIXME: Default to first TodoList until TodoLists CRUD is supported.
|
def todo_list
TodoList.find_by(user_id: current_user['sub'])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def first\n @todo.first! if @todo.may_first?\n redirect_to root_path\n end",
"def set_todolist\n @todolists = Todolist.find(params[:id])\n end",
"def set_todo_list\n @todo_list = TodoList.find(params[:id])\n end",
"def set_todo_list\n @todo_list = TodoList.find(params[:id])\n end",
"def set_todo_list\n @todo_list = TodoList.find(params[:id])\n end",
"def set_todo_list\n @todo_list = TodoList.find(params[:id])\n end",
"def index\n @todoit_lists = TodoitList.all\n end",
"def set_todo_item\n @todo_list.todo_items.find(:id)\n end",
"def set_todo_list\n @todo_list = TodoList.find(params[:todo_list_id])\n end",
"def set_todo_list\n @todo_list = TodoList.find(params[:todo_list_id])\n end",
"def set_todolist\n @todolist = Todolist.find(params[:id])\n end",
"def set_listtodo\n @listtodo = Listtodo.find(params[:id])\n end",
"def set_todolist\n @todolist = Todolist.find(params[:id])\n end",
"def index\n @todolists = Todolist.all\nend",
"def set_todo\n\t\t\t@list = current_user.lists.find(params[:list_id])\n @todo = @list.todos.find(params[:id])\n end",
"def find_todolist\n @todolist = Todolist.find(params[:todolist_id])\n end",
"def set_todoit_list\n @todoit_list = TodoitList.find(params[:id])\n end",
"def set_todo_list\n begin\n @todo_list = current_user.todo_lists.where(project_id: params[:project_id]).find(params[:id])\n rescue => exception\n head 401\n end\n end",
"def index\n\t\t@list = current_user.lists.find(params[:list_id])\n @todos = @list.todos\n end",
"def set_todoslist\n @todoslist = Todoslist.find(params[:id])\n end",
"def index\n @todoslists = Todoslist.all\n end",
"def get_list(id)\n record \"/todos/list/#{id}\"\n end",
"def get(id:)\n list = client.get_list(id: id)\n\n Todoable::List.new(list)\n end",
"def list_todo_items(opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n {}\n \n )\n\n # resource path\n path = path_replace(\"/v1/users/self/todo\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end",
"def show\n @todo = @list.todos.find(params[:id])\n end",
"def index\n @todos = @list.todos.all\n end",
"def index\n @todoitems = @todolist.todoitems.order(:created_at)\n end",
"def index\n @listtodos = Listtodo.all\n end",
"def create\n @todo = Todo.new(todo_params)\n if params[:todo][:list_id].present?\n @todo.list = List.find(params[:todo][:list_id])\n elsif params[:todo][:list].present?\n @todo.list = List.find(params[:todo][:list].to_i)\n else\n redirect_to root_path, notice: 'Error while adding new todo.'\n end\n\n respond_to do |format|\n if @todo.save\n format.html { redirect_to @todo.list, notice: 'Todo was successfully created.' }\n format.json { render :show, status: :created, location: @todo }\n else\n format.html { redirect_to @todo.list }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @listitems = @todolist.listitems\nend",
"def set_todo_item\n @todo_item = @todo_list.todo_items.find(params[:id])\n end",
"def first_item\n self.simple_acts_as_list_scope.first\n end",
"def load_todo(list, id)\n list[:todos].find { |todo| todo[:id] == id }\nend",
"def show\n @todo_item = @todo_list.todo_items.find(params[:id])\n end",
"def new\n @list = List.find(params[:id])\n @todolist = @list.todolists.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todolist }\n end\n end",
"def load_todo(id)\n @list[:todos].find { |todo| todo[:id] == id }\nend",
"def index\n @todo_lists = TodoList.where(work_id: params[:id]).order(\"created_at\").page(params[:page]).per(5)\n end",
"def todo_object\n task = Todo.find_by_id(self.todo_id)\n return task\n end",
"def index\n @todo_apps = TodoApp.all\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n redirect_to login_path unless @todo.list.user == current_user\n end",
"def set_todo\n @todo = Todo.global.find(params[:id])\n end",
"def new\n @todo = @list.todos.build\n end",
"def set_todo\n @todo = @project.todos.find(params[:id])\n end",
"def todo\n @tasks = TaskDecorator.decorate_collection Task.getReadyToDoTasks\n render \"v1/tasks/index\"\n end",
"def select\n # new_list = TodoList.new(\"Selected Todos\")\n new_list = TodoList.new(title) # should probably keep the original title\n self.each do |todo| # don't need to use 'self.each' here (just use 'each')\n new_list.add(todo) if yield(todo)\n end\n new_list # rtn a TodoList obj\n end",
"def index\n @todos = Todo.all\n end",
"def index\n @todos = Todo.all\n end",
"def index\n @todos = Todo.all\n end",
"def index\n @todos = Todo.all\n end",
"def index\n @todos = Todo.all\n end",
"def index\n @todos = Todo.all\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def index\n @todos = Todo.all.order(created_at: :desc)\n end",
"def index\n @todo_items = @todo_list.todo_items.all.order(\"completed ASC\") \n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def get_todos(data_store, id, list, mode)\n mode ? data_store.find_todos(id) : list[:todos]\nend",
"def index\n @to_dos = ToDo.all\n end",
"def select\n counter = 0\n new_list = TodoList.new(title)\n\n while counter < @todos.length do\n if yield(@todos[counter])\n new_list << @todos[counter]\n end\n counter += 1\n end\n\n new_list\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def update(id:, name:)\n list = client.update_list(id: id, name: name)\n\n Todoable::List.new(list)\n end",
"def select\n new_list = TodoList.new(\"Selected Items\")\n\n each do |todo|\n new_list.add(todo) if yield(todo)\n end\n new_list\n end",
"def next_todo\n jid = redis.with { |c| c.brpoplpush('antelopes:todo', 'antelopes:doing', timeout: 1) }\n\n return if jid.nil?\n Job.new(JSON.parse(redis.with { |c| c.get(\"antelopes:job:#{jid}\") }))\n end",
"def new\n @list_to_do = ListToDo.new\n #@list_to_dos = ListToDo.all\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_to_do }\n end\n end",
"def create(name:)\n attributes = client.create_list(name: name)\n\n Todoable::List.new(attributes)\n end",
"def edit\n\t\t@todolist = Todolist.find(params[:id])\n\tend",
"def set_todo\n @todo = Todo.find(params[:id])\n end",
"def index\n @todolist = Todolist.find(params[:todolist_id])\n @task = @todolist.tasks.find(params[:id])\n\n @tasks = @todolist.tasks.where(completed: false).order('created_at ASC')\n @completed_tasks = @todolist.tasks.where(completed: true).order('updated_at')\n end",
"def pick_todo\n if Todo.allTodos.empty?\n system \"clear\"\n puts 'Please add todos, before you can edit them.'.yellow\n return main_menu\n end\n\n puts 'What todo?'\n Todo.display_todos\n todo_index = check_for_exit(gets.chomp).to_i\n Todo.new(Todo.allTodos[todo_index]);\n\nend",
"def show\n @todo = @list.todos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @todo }\n end\n end",
"def set_task\n @task = Task.includes(:todo).find(params[:id])\n @todo = @task.todo\n @list = @todo.list\n end",
"def item_at(index)\n @todos[index]\n end",
"def get_items(projectid, todolistid)\n get(\"projects/#{projectid}/todolists/#{todolistid}.json\")\n end",
"def index\n @todos = @user.todos\n end",
"def show\n\t\t@to_do_list = ToDoList.find(params[:id])\n\t \tif(@to_do_list.user_id == current_user.id)\n\t\t respond_to do |format|\n\t\t format.html # show.html.erb\n\t\t format.json { render json: @to_do_list }\n\t\t end\n\t\telse\n\t\t \tredirect_to to_do_lists_path\n\t\tend\n end",
"def create\n\t @list = current_user.lists.find(params[:list_id])\n @todo = @list.todos.new(todo_params)\n respond_to do |format|\n if @todo.save\n\t @todo.move_to_top\n format.html { redirect_to list_todos_path, notice: 'Todo was successfully created.' }\n format.json { render action: 'show', status: :created, location: [@list, @todo] }\n\t\t\t\t#format.js { render template: \"todos/create.json.erb\" }\n\t\t\t\tformat.js { render json: { element: render_to_string( partial: 'list', locals: { todo: @todo } ) } }\n else\n format.html { render action: 'new' }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_todo(todo)\n post_params = {\n :body => todo.post_json,\n :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})\n }\n \n response = Logan::Client.post \"/projects/#{@project_id}/todolists/#{@id}/todos.json\", post_params\n Logan::Todo.new response\n end"
] |
[
"0.6672769",
"0.65580666",
"0.65246356",
"0.65246356",
"0.65246356",
"0.6517467",
"0.6502787",
"0.6447455",
"0.64415413",
"0.6424842",
"0.6406425",
"0.6404615",
"0.6388647",
"0.63870126",
"0.63340926",
"0.63278043",
"0.627213",
"0.6262549",
"0.6233896",
"0.6195576",
"0.6162241",
"0.61297554",
"0.6126589",
"0.6104048",
"0.6076453",
"0.6049619",
"0.6039407",
"0.602494",
"0.60049963",
"0.59928155",
"0.59735423",
"0.5956341",
"0.5955784",
"0.59556526",
"0.592235",
"0.59198886",
"0.5909216",
"0.58521885",
"0.58133405",
"0.5812102",
"0.5792698",
"0.57912105",
"0.5777543",
"0.5757879",
"0.57481605",
"0.57237005",
"0.57237005",
"0.57237005",
"0.57237005",
"0.57237005",
"0.57237005",
"0.5697058",
"0.5697058",
"0.5697058",
"0.5697058",
"0.5697058",
"0.56911045",
"0.5673011",
"0.56704587",
"0.5666203",
"0.5666175",
"0.5663378",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.56508315",
"0.5644208",
"0.5638949",
"0.56373906",
"0.56332093",
"0.5629926",
"0.5623125",
"0.56178147",
"0.561173",
"0.5602904",
"0.5581166",
"0.5580185",
"0.55693877",
"0.5559848",
"0.55504346",
"0.5536171",
"0.55356145",
"0.55335724"
] |
0.6411786
|
10
|
STEPS: 1. save something in mb as visitor 2. OAuth login with Facebook VIA mobile path 3. confirm UGC merge on my book
|
def test_visitor_merge_through_facebook
@user.email = @fb_user['email']
# Step 1
assign_http(Config["panda"]["host"])
# convert to search
params = {
'type' => { 'shortcuts' => ['gas'] },
'vrid' => @user.vrid
}
post '/mb/preferences', params
assert_response(@response, :success)
# Step 2
params = {
'vrid' => @user.vrid,
'merge_history' => true
}
assign_http(Config["turtle"]["host"])
get '/auth/facebook', params
assert_response(@response, 302)
assert_match(/https:\/\/www\.facebook\.com/, @response['location'])
login_fb_user!(@fb_user, @user)
# Step 3
assign_http(Config["panda"]["host"])
params = {
'type' => 'shortcuts',
'user_id' => @parsed_response['id']
}
get '/mb/preferences', params
assert_response(@response, :success)
assert_equal(1, @parsed_response['Shortcuts'].size)
assert_equal('gas', @parsed_response['Shortcuts'].first['Name'])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_unverified_user_fb_sign_up_ugc_merge\n # Step 1\n @user.email = @fb_user['email']\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n @user.login_oauth\n assert(@user.oauth_token)\n\n # Step 2\n assign_http(Config[\"panda\"][\"host\"])\n\n opts = { 'vrid' => @user.vrid }\n\n get_consumer_search_resp('ramen', 'glendale, ca', opts)\n\n assert_response(@response, :success)\n\n listing = @parsed_response['SearchResult']['BusinessListings'].first\n int_xxid = listing['Int_Xxid']\n\n # Step 3\n assign_http(Config[\"monkey\"][\"host\"])\n\n headers = { 'Content-Type' => 'image/jpg' }\n\n params = {\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'oauth_token' => @user.oauth_token,\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n put_file \"/b_image\", params, generate_random_image, headers\n\n assert_response(@response, :success)\n sha1 = @parsed_response['id']\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n post \"/b_image/#{sha1}\", params\n\n assert_response(@response, :success)\n\n # Step 4\n refute_image_in_consumer_business(sha1, listing)\n assert_image_in_profile(sha1, @user)\n\n # Step 5\n login_fb_user!(@fb_user, @user)\n\n # Step 6\n assert_image_in_consumer_business(sha1, listing)\n assert_image_in_profile(sha1, @user)\n\n # Step 7\n assign_http(Config[\"monkey\"][\"host\"])\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'reason' => 6\n }\n\n post \"/b_image/#{sha1}/int_xxid/#{int_xxid}/report\", params\n assert_response(@response, :success)\n\n params = { 'api_key' => Config[\"monkey\"][\"api_key\"] }\n\n get \"/business/images/#{int_xxid}\", params\n assert_response(@response, :success)\n refute_empty(@parsed_response[int_xxid],\n \"Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}\")\n refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1),\n \"Expected image removed from list after delete: #{sha1}\")\n end",
"def oauth_callback\n at = Marshal.load(session[:qb_request_token]).get_access_token(:oauth_verifier => params[:oauth_verifier])\n \n #There can only be one...\n Qbo.destroy_all\n\n # Save the authentication information \n qbo = Qbo.new\n qbo.qb_token = at.token\n qbo.qb_secret = at.secret\n qbo.token_expires_at = 6.months.from_now.utc\n qbo.reconnect_token_at = 5.months.from_now.utc\n qbo.company_id = params['realmId']\n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n end",
"def prepare_to_publish\n manager = OauthManager.new(@vehicle)\n @oauth = manager.oauth\n redirect_to manager.url\n\n rescue Exception => e\n flash[:error] = \"No se pudo autenticar con Facebook. #{e}\"\n redirect_to vehicles_path\n end",
"def test03_fb_login_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\t\t\n\t\tfb_allow\n\t\t$browser.goto($facebook_home)\n\t\t$facebook_dropdown.click\n\t\t$facebook_logout.click\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T3: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def Managerfb\n session[:check] = 1\n redirect_to '/auth/facebook'\n end",
"def test04_fb_login_existing_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($facebook_home)\n\t\tfb_login\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T4: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def complete_gift_transaction\n # find gift and user from gift state..safely preserved thru the wormhole!\n decoded_gift_state = ActiveSupport::JSON.decode(params[:gift_state])\n gift_template = GiftTemplate.find(decoded_gift_state['gift_template_id'])\n current_individual_user = IndividualUser.find(\n decoded_gift_state['individual_user_id'])\n access_token = decoded_gift_state['access_token']\n if decoded_gift_state['recipient'] = \"self\"\n recipient_id = current_individual_user.id\n else\n recipient_id = IndividualUser.find_by_facebook_id(\n decoded_gift_state['recipient']).id\n end\n\t is_private = decoded_gift_state['is_private']\n \n # log points and create record of sent gift\n current_individual_user.increment_user_points(1)\n user_gift = UserGift.new(:individual_user_id => recipient_id, \n :sender_user_id => current_individual_user.id, \n :gift_template_id => gift_template.id, :time_acquired => Time.now)\n user_gift.status = \"sent\" \n user_gift.save\n\t\n if (gift_template.quantity_available < 10000)\n gift_template.decrease_quantity_available(1)\n end\n\t\n\t # return user to app, preserving platform login creds,\n # and redirecting to proper organization storefront\n\t if decoded_gift_state['page_tab_id']\n\t\t graph = Koala::Facebook::API.new\n\t page_tab = graph.get_object(\"#{decoded_gift_state['page_tab_id']}\")\n\t\t if page_tab[\"link\"]\n\t\t encoded_page_state = URI.encode(ActiveSupport::JSON.encode(\n {:pathway => \"gift_sent\", \n :organization_id => gift_template.organization_id, \n :individual_user_id => current_individual_user.id, \n :secret => access_token}))\n\t\t redirect_to(page_tab[\"link\"] + \n \"?sk=app_#{APP_ID}&app_data=#{encoded_page_state}\")\n\t\t else #No link provided..user brought to main app\n\t\t redirect_to \"index\" \n\t\t end\n\t else\n\t redirect_to(FACEBOOK_URL + \"?pathway=#{'gift_sent'}&\" +\n \"organization_id=#{gift_template.organization_id}&\" +\n \"individual_user_id=#{current_individual_user.id}&\" + \n \"secret=#{access_token}\")\n\t end\n\t return\n \n # rescue from all the badness\n rescue\n flash[:notice] = \"Your Trinkon could not be posted to Facebook.\"\n redirect_to(:controller => \"app\", \n :action => \"give_gift\", :gift_template_id => gift_template.id)\n return\n end",
"def oauth\n profile = OAuthProfile.from_omniauth(env['omniauth.auth'])\n # TODO check for error\n # temp_password = SecureRandom.hex\n if !profile.user\n oauth_custom_params = request.env[\"omniauth.params\"] || {}\n session[:oauth_reason] = oauth_custom_params.fetch(\"dbdesigner_action\", \"\")\n session[:profile_id] = profile.id\n redirect_to new_registration_path\n # profile.user.create({\n # username: profile.username,\n # email: profile.email,\n # password: temp_password,\n # password_confirmation: temp_password\n # })\n else\n session[:user_id] = profile.user.id\n profile.user.record_login(request: request, oauth_profile: profile)\n redirect_to designer_path\n end\n end",
"def create_fb_url_with_creds(indv_u_id, ac_token, decoded_state: nil)\n url = FACEBOOK_URL + \"?individual_user_id=#{indv_u_id}&secret=#{ac_token}\"\n if decoded_state\n url += \"pathway=#{decoded_state['pathway']}\" +\n \"&gift_template_id=#{decoded_state['gift_template_id']}\" \n end\n \n #Creates facebook oauth dialog url\n #--PE 10/30/14\n def create_oauth_url(cb_url, encoded_auth_state)\n oauth_url = \"https://www.facebook.com/dialog/oauth/?client_id=\" +\n \"#{APP_ID}&redirect_uri=#{cb_url}&state=#{encoded_auth_state}\"\n end\n\n #########\n protected\n ######### \n\n #Renew the access_token after API failure --PE July 17, 2012\n def rescue_api_error\n session.delete(:access_token)\n\t session.delete(:individual_user_id)\n\t oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, AUTH_CALLBACK)\n\t redirect_to(:action => \"exit_portal\", :url => oauth.url_for_oauth_code)\n end\n\n #Redirect to app index page after connection is reset --PE July 23, 2012\n def rescue_connection_reset\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (connection reset). \" +\n \"Please try again.\"\n end\n\n #Redirect to app index page after undefined method errors --PE July 23, 2012\n def rescue_undefined_method\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (undefined method). \" +\n \"Please try again.\"\n end\nend",
"def facebook_callback\n if params[:error_reason]\n redirect_to :controller => :home, :action => :index\n return\n end\n oauth_info = OauthToken.get_oauth_info('facebook')\n uri = URI.parse(\"https://graph.facebook.com/oauth/access_token\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n new_params = {:client_id => oauth_info['consumer_key'],\n :client_secret => oauth_info['consumer_secret'],\n :redirect_uri => oauth_info['callback'],\n :code => params[:code]}\n \n request = Net::HTTP::Post.new(uri.request_uri)\n request.set_form_data(new_params)\n response = http.request(request)\n \n fields = response.body.split('=')\n access_token = fields[1]\n\n oauth_token = OauthToken.find_by_token_and_site_token(access_token,'facebook')\n \n if current_user and oauth_token.present? and oauth_token.user and current_user != oauth_token.user\n redirect_to :controller => :oauth, :action => :duplicate_users, :id => oauth_token.id\n return\n end\n\n # Create the Oauth token\n if oauth_token\n oauth_token.update_attributes({:site_token => 'facebook',\n :site_name => \"Facebook\",\n :token => access_token}) \n oauth_token.get_user_info\n else\n oauth_token = OauthToken.create({:user_id => (current_user ? current_user.id : nil),\n :site_token => 'facebook',\n :site_name => \"Facebook\",\n :token => access_token}) \n oauth_token.get_user_info\n \n TrackedAction.add(:connected_to_third_party_site, oauth_token.user)\n TrackedAction.add(:connected_to_facebook, oauth_token.user)\n oauth_token.user.give_level_up_credits(10)\n end\n\n OauthToken.delay.autofollow_friends(oauth_token.id)\n\n flash[:authenticated_facebook] = 1\n if !session[:redirect_after_oauth].blank?\n redirect_to session[:redirect_after_oauth]\n session[:redirect_after_oauth] = nil\n else\n redirect_to :controller => :home, :action => :index\n end\n end",
"def fb_auth\n session[:sign_up_reason] = nil\n\n if params[:return_to]\n set_after_sign_in_location(params[:return_to])\n elsif params[:spree_user_return_to]\n set_after_sign_in_location(params[:spree_user_return_to])\n elsif is_user_came_from_current_app\n set_after_sign_in_location(request.referrer)\n end\n\n if params[:redeem_via_fb_state]\n session[:redeem_via_fb_state] = params[:redeem_via_fb_state]\n end\n\n if params[:new_modal_fb_state]\n session[:new_modal_fb_state] = params[:new_modal_fb_state]\n end\n\n if params[:show_promocode_modal]\n session[:show_promocode_modal] = params[:show_promocode_modal]\n # reset current modal popup\n set_after_sign_in_location(root_path)\n end\n\n session[:auto_apply] = params[:auto_apply] if params.key?(:auto_apply)\n session[:auto_apply_promo] = params[:auto_apply_promo] if params.key?(:auto_apply_promo)\n\n # Capture PLEASE REMIND ME ABOUT MY SALE events to push onto customer.io later.\n session[:email_reminder_promo] = params[:email_reminder_promo] if params.key?(:email_reminder_promo)\n\n\n redirect_to spree.spree_user_omniauth_authorize_url(provider: :facebook, scope: 'email,public_profile,user_friends')\n end",
"def grantAccess()\n\t\t\tif File.zero?('lib/data.txt') #if files doesn't exist it then gets the access_tokens\n\t\t\t\t@request_token = @consumer.get_request_token\n\t\t\t\tLaunchy.open(\"#{@request_token.authorize_url}\")\n\t\t\t\tprint \"Enter pin that the page gave you:\" \n\t\t\t\t@pin = STDIN.readline.chomp\n\t\t\t\t@access_token = @request_token.get_access_token(:oauth_verifier => @pin)\n\t\t\t\tputs @access_token.token\n\t\t\t\tFile.open('lib/data.txt','w') do |f|\n\t\t\t\t\tf.puts @access_token.token\n\t\t\t\t\tf.puts @access_token.secret\n\t\t\t\tend\n\t\t\telse #if they exist it simple reads them into token_hash\n\t\t\t\tFile.open('lib/data.txt','r') do |f|\n\t\t\t\t\t@token_hash = { :oauth_token => f.readline.chomp,\n\t\t\t\t\t\t\t\t\t\t\t :oauth_token_secret => f.readline.chomp\n\t\t\t\t\t\t\t\t\t\t \t\t}\n\t\t\t\t\tend\n\t\t\tend\n\t\tend",
"def test_23_loginviagmailandfb()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 23 ----------------------\"\n\t\tloginViaGmail($gmail_emailId, $gmail_password)\n\t\tlogout()\n\t\tloginViaFacebook($fb_emailId, $fb_password)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 23 ----------------------\"\n\t\n\tend",
"def facebook\n handle_oauth\n end",
"def create_from_oauth\n if stored_anonymous_user?\n user, from_registration = update_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n else\n user, from_registration = create_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n end\n\n if user.errors.any?\n redirect_to_registration_page(user)\n else\n change_global_user_id(user.id)\n sign_in(user)\n fandom_play_login(user)\n \n if from_registration\n log_data = { 'form_data' => env[\"omniauth.auth\"], 'user_id' => current_user.id }\n log_synced(\"registration from oauth\", adjust_user_and_log_data_with_utm(user, log_data))\n\n set_account_up()\n cookies[:from_registration] = true \n end\n\n if $site.force_facebook_tab && !request_is_from_mobile_device?(request)\n redirect_to request.site.force_facebook_tab\n else\n redirect_after_oauth_successful_login()\n end\n end\n end",
"def return_from_gift_auth\n # back from oauth wormhole..obtain facebook user and credentials\n\t oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GIFT__AUTH_CALLBACK)\n\t session[:access_token] = oauth.get_access_token(params[:code])\n\t graph = Koala::Facebook::API.new(session[:access_token])\n\t facebook_user_id = graph.get_object(\"me\")[\"id\"]\n\t session[:individual_user_id] = IndividualUser.login_or_create(\n facebook_user_id,session[:access_token])\n\n\t unless params[:state] # no state param..forgetaboutit\n\t\t redirect_to(create_fb_url_with_creds(session[:individual_user_id],\n session[:access_token])) and return\n\t end\n\t\n\t #[Page Tab] determine if we came from page tab..if so, back to Kansas\n\t decoded_state = ActiveSupport::JSON.decode(params[:state])\n page_id, link = false, false\n\t if decoded_state['page_tab_id']\n page_id = true\n\t\t graph = Koala::Facebook::API.new\n\t\t page_tab = graph.get_object(\"#{decoded_state['page_tab_id']}\")\n\t\t if page_tab[\"link\"]\n link = true\n\t\t encoded_page_state = URI.encode(ActiveSupport::JSON.encode(\n {:pathway => decoded_state['pathway'], \n :gift_template_id => decoded_state['gift_template_id'], \n :individual_user_id => session[:individual_user_id], \n :secret => session[:access_token]}))\n\t\t end\n\t end\n \n # handle the redirect\n if page_id && link\n redirect_to(page_tab[\"link\"] + \n \"?sk=app_#{APP_ID}&app_data=#{encoded_page_state}\")\n else\n\t redirect_to(create_fb_url_with_creds(session[:individual_user_id], \n session[:access_token], decoded_state))\n end\n\t return\n end",
"def facebook\n\n end",
"def test_fb_sign_up_and_upload_monkey_image\n # Step 1\n @user.email = @fb_user['email']\n login_fb_user!(@fb_user, @user)\n\n # Step 2\n assign_http(Config[\"panda\"][\"host\"])\n\n opts = { 'vrid' => @user.vrid }\n\n get_consumer_search_resp('ramen', 'glendale, ca', opts)\n assert_response(@response, :success)\n\n listing = @parsed_response['SearchResult']['BusinessListings'].first\n int_xxid = listing['Int_Xxid']\n\n # Step 3\n assign_http(Config[\"monkey\"][\"host\"])\n\n headers = { 'Content-Type' => 'image/jpg' }\n\n params = {\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'oauth_token' => @user.oauth_token,\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n put_file \"/b_image\", params, generate_random_image, headers\n assert_response(@response, :success)\n\n sha1 = @parsed_response['id']\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n post \"/b_image/#{sha1}\", params\n assert_response(@response, :success)\n\n # Step 4\n assert_image_in_consumer_business(sha1, listing)\n assert_image_in_profile(sha1, @user)\n\n # Step 5\n assign_http(Config[\"monkey\"][\"host\"])\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'reason' => 6\n }\n\n post \"/b_image/#{sha1}/int_xxid/#{int_xxid}/report\", params\n assert_response(@response, :success)\n\n params = { 'api_key' => Config[\"monkey\"][\"api_key\"] }\n\n get \"/business/images/#{int_xxid}\", params\n assert_response(@response, :success)\n refute_empty(@parsed_response[int_xxid],\n \"Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}\")\n refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1),\n \"Expected image removed from list after delete: #{sha1}\")\n end",
"def post_authorize\n oauth_token = FitbitOauthToken.find_by_token(params[:oauth_token])\n if oauth_token\n user = oauth_token.user\n client = user.get_fitbit_client \n access_token = client.authorize(oauth_token.token,oauth_token.secret,{:oauth_verifier=>params[:oauth_verifier]})\n User.transaction do\n oauth_token.update_attributes :token => access_token.token, :secret => access_token.secret\n user.retrieve_fitbit_user\n user.reload\n user.fitbit_user.subscribe_to_notifications\n user.fitbit_user.request_activity_through_today(false)\n notification = user.notifications.find_by_key('FITBIT') || user.notifications.build(:key=>'FITBIT')\n \n if user.profile.started_on >= user.promotion.current_date\n notification.update_attributes :title => \"Fitbit Connected\", :message=>\"Your Fitbit data will sync with <em>#{Constant::AppName}</em> starting #{user.profile.started_on.strftime('%B %e')}.\"\n else\n notification.update_attributes :title => \"Fitbit Connected\", :message=>\"Your Fitbit data will sync with <em>#{Constant::AppName}</em> shortly.\"\n end\n \n user.update_column :active_device, 'FITBIT'\n end\n extra_data = oauth_token.parse_extra_data\n redirect_to extra_data[:return_url]\n else\n render :text=>\"Error: Fitbit OAuth failure\"\n end\n end",
"def proc_facebook_login\n \n puts \"proc_facebook_login\"\n \n puts request.env['rack.auth'].inspect\n \n \n # If user is already logged in, grab session variables\n if session[:user_name] && !session[:user_name].empty?\n @real_name = session[:real_name] \n @user_name = session[:user_name]\n @user_image = session[:user_image] \n else\n # If user is not logged in, grab authentication varaibles\n @real_name = request.env['rack.auth']['user_info']['name']\n @user_name = request.env['rack.auth']['user_info']['name']\n #@user_image = request.env['rack.auth']['user_info']['image']\n @user_image = \"\"\n \n session[:user_name] = @user_name\n session[:real_name] = @real_name\n session[:user_image] = @user_image \n end\n \n @exists = false\n @user_id = -1\n \n #puts \"Checking if user already exists in database...\"\n \n # Check if user already exists in database\n User.all.each do |user|\n if user[:twitter] == @user_name\n @exists = true\n @user_id = user.id\n session[:user_id] = @user_id\n break;\n end\n end\n \n # User does not exist in database. Add new user\n if !@exists\n new_user = User.new( :twitter => @user_name, :name => @real_name )\n new_user.save\n \n @user_id = new_user.id\n session[:user_id] = @user_id\n end\n \n # Redirect to the user home page\n redirect_to :action => \"home\"\n end",
"def facebook\n end",
"def save_it(values)\n mp on_save: data = values\n\n\n App::Persistence['available'] = false\n\n p data['email']\n SVProgressHUD.showWithStatus(\"Signing In...\", maskType:SVProgressHUDMaskTypeBlack)\n params = { user: {email: \"#{data['email']}\", password:\"#{data['password']}\" }}\n AFMotion::JSON.post(\"#{BASE_URL}/sessions.json\", params) do |result|\n if result.success?\n p result.object\n p \"token: #{result.object[\"data\"][\"auth_token\"]}\"\n #App::Persistence['auth_token'] = result.object[\"data\"][\"auth_token\"]\n App::Persistence['user_id'] = result.object[\"data\"][\"user_id\"]\n App::Persistence['user_name'] = result.object[\"data\"][\"name\"]\n App::Persistence['user_email'] = result.object[\"data\"][\"email\"]\n\n SVProgressHUD.dismiss\n #send info to Parse for pushes\n #app_delegate.parse_register\n\n # app_delegate.register_for_push_notifications :badge, :sound, :alert, :newsstand\n # PM.logger.info app_delegate.registered_push_notifications\n\n open GameSelectScreen.new(nav_bar:false)\n\n #app_delegate.get_location\n\n else\n SVProgressHUD.dismiss\n App.alert(\"Login failed\")\n App.alert(result.error.localizedDescription)\n end\n end\n end",
"def bookmarks_book_bags_login\n #binding.pry\n # hack to return to book_bags page after login\n session[:cuwebauth_return_path] = book_bags_index_path\n # redirect_to user_saml_omniauth_authorize_path\n redirect_post(user_saml_omniauth_authorize_path, options: {authenticity_token: :auto})\n end",
"def oauth_callback\n if params[:state].present?\n oauth2_client = Qbo.get_client\n # use the state value to retrieve from your backend any information you need to identify the customer in your system\n redirect_uri = Setting.host_name + \"/qbo/oauth_callback/\"\n if resp = oauth2_client.auth_code.get_token(params[:code], redirect_uri: redirect_uri)\n \n # Remove the last authentication information\n Qbo.delete_all\n \n # Save the authentication information \n qbo = Qbo.new\n qbo.company_id = params[:realmId]\n \n # Generate Access Token & Serialize it into the database\n access_token = OAuth2::AccessToken.new(oauth2_client, resp.token, refresh_token: resp.refresh_token)\n qbo.token = access_token.to_hash\n qbo.expire = 1.hour.from_now.utc\n \n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n \n end\n end\n end",
"def fbauthorize\n redirect_to fb_auth_login_url.to_s\n end",
"def finish_oauth\n\tRails.logger.warn 'here'\n\n @consumer = OAuth::Consumer.new('l9tUlXD0IOoGhC9HnDJBA', '9YZWGkxQJgieQ3Ta89mPE4xpXXhryEbRD9GS0WAt4',{:site=>\"http://twitter.com\" })\n @req_token = OAuth::RequestToken.new(@consumer,session[:request_token],session[:request_token_secret])\n \n # Request user access info from Twitter\n @access_token = @req_token.get_access_token\n\n # Store the OAuth info for the user\n #@user = {}\n #@user.update_attributes(:token=>@access_token.token,:token_secret=>@access_token.secret)\n Rails.logger.warn \"Second Request #{@access_token.params['user_id']}\"\n # Send the user on their way\n session[:tokens] ={:token=>@access_token.token, :token_secret=>@access_token.secret}\n session[:id] = @access_token.params['user_id']\n redirect_to '/'\nend",
"def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end",
"def new_session\n\n @session = DropboxSession.new(@APP_KEY, @APP_SECRET)\n\n #OAuth flow\n\n #step 1: get a request token\n @session.get_request_token\n\n #step 2: ask user to authorize linking app to Dropbox account\n authorize_url = @session.get_authorize_url(\"https://www.dropbox.com/home/Apps/Notational Data CL\")\n\n #make the user sign in and authorize this token\n puts \"AUTHORIZING\", authorize_url\n `open #{authorize_url}` #backticks indicate a bash command. see http://ruby-doc.org/core-2.0/Kernel.html#method-i-__method__\n puts \"Please visit this website and press the 'Allow' button, then hit 'Enter' here.\" #refactor this step into UI layer? perhaps a notify message?\n gets\n\n #step 3: once authorized, exchange the request token for an access token, which will be used for calling Core API\n #this will fail if the user didn't visit the above url and hit 'Allow'\n access_token = @session.get_access_token #shouldn't need to get access token again unless reinstall app or revoke access from Dropbox website\n\n ProcessLayer.store_session(@session.serialize)\n\n end",
"def create\n\t\tauth = request.env[\"omniauth.auth\"] #when press the link fb_login, response that is received from callback is stored in auth var\n\t\tsession[:omniauth] = auth.except('extra') #session var with info from response, except extra- info that we dont need\n\t\tcurrent_user = User.sign_in_from_omniauth(auth)\n\t\tsession[:user_id] = current_user.id\n\t\tredirect_to root_url, flash: { notice: \"#{current_user.name}, welcome to Like Machine.\"}\n\tend",
"def create\n @review = current_user.reviews.new #(params[:review])\n @review.creator_id = current_user.id\n @review.content = params[:review][:content]\n @review.reviewable_id = params[:review][:reviewable_id]\n @review.reviewable_type = params[:review][:reviewable_type]\n# @review.creator_id = params[:creator_id]\n# @review.place_id = params[:place_id] if params[:place_id]\n\n shared = false\n share = current_user.shares.find_by_provider(\"facebook\")\n if !share.nil?\n if share.share_review == true\n shared = true\n end\n end\n \n respond_to do |format|\n if @review.save\n if shared\n @content = @review.content\n @link = review_url(@review) #\"http://www.koedok.com\" #\n @name = \"www.koedok.com\"\n @user = current_user\n# graph.put_wall_post(content, {:name => name, :link => link})\n FbshareWorker.perform_async(@user.id, @content, @name, @link)\n# FbshareWorker.perform_async(token, content, name, link)\n# graph.put_wall_post(\"home\", {:name => \"place1\", :link => \"http://www.koedok.com\"})\n #graph.put_wall_post(\"home\", {:name => \"place1\", :link => review_path(@review)})\n end\n if false #disabled, not working with fb share\n @activity = Activity.create!(:user_id => @review.creator.id, :activity_type => Activity::CREATE_REVIEW, :target_type => @review.class.name, :target_id => @review.id)\n end\n# @activity = Activity.add(@review.creator, Activity::CREATE_REVIEW, @review, @review)\n# PrivatePub.publish_to(\"/reviews/new\", \"alert('#{@review.content}');\")\n #PrivatePub.publish_to(\"/reviews/new\", \"eval('#{@review.content}');\")\n format.html { redirect_to review_path(@review), :notice => t(:review_created) }\n format.json { render json: @review, status: :created, location: @review }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #request_token = @client.request_token(:oauth_callback => 'http://127.0.0.1:3000/twitter/new')\n #request_token = @client.request_token(:oauth_callback => 'https://gentle-snow-7462.herokuapp.com/twitter/new')\n request_token = @client.request_token(:oauth_callback => TWITTER_CALLBACK_URL)\n\n session['oauth_request_token_token'] = request_token.token\n session['oauth_request_token_secret'] = request_token.secret\n\n redirect_to request_token.authorize_url\n end",
"def return_from_general_auth\t\n # back from oauth wormhole..obtain facebook user and credentials\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GEN_AUTH_CALLBACK)\n session[:access_token] = oauth.get_access_token(params[:code])\n graph = Koala::Facebook::API.new(session[:access_token])\n facebook_user_id = graph.get_object(\"me\")[\"id\"]\n session[:individual_user_id] = \n IndividualUser.login_or_create(facebook_user_id,session[:access_token])\n\n # determine where to redirect\n state, link = false, false\n\t if params[:state]\n state = true\n decoded_state = ActiveSupport::JSON.decode(params[:state])\n \n # [Page Tab] return to the page tab\n if decoded_state['page_tab_id']\n\t\t\t graph = Koala::Facebook::API.new\n\t\t\t page_tab = graph.get_object(\"#{decoded_state['page_tab_id']}\")\n\t\t\t if page_tab[\"link\"]\n link = true\n\t\t\t\t encoded_page_state = URI.encode(ActiveSupport::JSON.encode(\n {:individual_user_id => session[:individual_user_id], \n :secret => session[:access_token]\n }))\n end\n end\n end\n \n # handle the redirect\n if state && link\n redirect_to(page_tab[\"link\"] + \n \"?sk=app_#{APP_ID}&app_data=#{encoded_page_state}\")\n else\n redirect_to(create_fb_url_with_creds(session[:individual_user_id],\n session[:access_token]))\n end\n return\n end",
"def verify\n\n # if we haven't already authenticated a user in the sample app.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n unless current_user.present?\n\n # we need to fetch the contents of a url, so include required libraries.\n require 'open-uri'\n\n # swap out our single-use token which was provided by kpass, for a secret\n # access key and some other user details for this user. this is standard\n # oauth stuff.\n verify_url = \"#{ENV['KPASS_ENDPOINT']}/oauth/verify?api_key=#{ENV['KPASS_API_KEY']}&token=#{params[:token]}\"\n # puts verify_url\n\n json = open(verify_url).read\n response = JSON.parse(json)\n\n # puts \"\"; puts \"%%%%%%%%%%\"; puts \"verify\"; puts response.inspect; puts \"\"\n\n # find or create a new user based on the username of the kpass account.\n # for over-13 users, the json will include their username (since they're\n # allowed to authorize the sharing of it.) if it's not present (because\n # they're under 13,) we generate a temporary random username that will be\n # replaced when the parent authorizes kpass to share the user's username\n # with the sample app. it will arrive via a webhook and is handled in\n # another method below. random_username is also defined below.\n kpass_id = response[\"member\"][\"id\"]\n username = response[\"member\"][\"username\"] || random_username\n\n # only create a new user record for them if we don't already have a user\n # record for their unique id.\n # @user = User.find_or_create_by(kpass_id: kpass_id)\n # \n # \n @user = User.find_or_create_by(kpass_id: kpass_id)\n # @user = User.where(:kpass_id => kpass_id, :username => username).first_or_create\n\n\n # set or update the username.\n @user.username = username\n\n @user.password = 'batterypop' #devise throws exception without a password upon save\n @user.birthday = response[\"member\"][\"birthday\"]\n @user.gender = response[\"member\"][\"gender\"]\n @user.username_avatar_age_gender = response[\"keys\"][\"username_avatar_age_gender\"]\n @user.access_to_moderated_chats = response[\"keys\"][\"access_to_moderated_chats\"]\n @user.youtube_and_3rdparty_videos = response[\"keys\"][\"batterypop_youtube_and_3rdparty_videos\"]\n @user.publish_public_profile = response[\"keys\"][\"batterypop_publish_public_profile\"]\n\n @user.approved = response[\"approved\"]\n @user.rejected = response[\"rejected\"]\n\n # store the api key we have for this user.\n @user.kpass_access_key = response[\"access_key\"]\n\n # save the user in the sample app.\n if @user.save\n sign_in(@user)\n # @_current_user = @user\n # cookies[:current_user_id] = @user.id\n # cookies[:current_user_kpass_id] = kpass_id #trying to find a way around post method not getting current_user\n else\n raise Exception.new(@user.errors.full_messages)\n end\n end\n\n # if the user was bumped into the authorization workflow because they tried\n # to do something in the app that required authentication..\n # (this is a feature of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # if session['previous_url'].present?\n\n # redirect_to session[:previous_url]\n\n # puts \"\"; puts \" $$*($*$*$*$ \"; puts \"REDIREC TO PREVIOUS URL\"; puts \"\";\n \n # else\n\n # puts \"\"; puts \" $$*($*$*$*$ \"; puts \"REDIREC TO /USERS\"; puts \"\";\n\n # redirect_to \"/users\"\n\n # end\n # \n \n redirect_to \"/users\"\n\n end",
"def test_fb_user_signup_then_login_logout_multiple_times\n @user.email = @fb_user['email']\n\n # Step 1\n params = {\n 'vrid' => @user.vrid,\n 'merge_history' => true\n }\n\n assign_http(Config[\"turtle\"][\"host\"])\n\n get '/auth/facebook', params\n assert_response(@response, 302)\n assert_match(/https:\\/\\/www\\.facebook\\.com/, @response['location'])\n\n login_fb_user!(@fb_user, @user)\n assert(@user.oauth_token)\n\n lookup_user_by_id(@user.id)\n fb_uid = @parsed_response['facebook_uid']\n\n # Step 2\n get_user_info(@user.oauth_token)\n assert(@parsed_response['accounts'].length >= 1, @parsed_response)\n fb_account = @parsed_response['accounts'].first\n assert_equal('FacebookAccount', fb_account['type'], fb_account)\n assert(fb_account['identifier'], fb_account)\n\n get_dragon_user(@user.id)\n assert_response(@response, :success)\n\n assert(@parsed_response['facebook_uid'], @parsed_response)\n assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)\n\n # Step 3\n turtle_response = @user.logout\n assert_response(turtle_response, :redirect)\n\n get_dragon_user(@user.id)\n assert_response(@response, :success)\n\n assert(@parsed_response['facebook_uid'], @parsed_response)\n assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)\n\n # Step 4\n params = {\n 'vrid' => @user.vrid,\n 'merge_history' => true\n }\n\n assign_http(Config[\"turtle\"][\"host\"])\n\n get '/auth/facebook', params\n assert_response(@response, 302)\n assert_match(/https:\\/\\/www\\.facebook\\.com/, @response['location'])\n\n login_fb_user!(@fb_user, @user)\n assert(@user.oauth_token)\n\n get_user_info(@user.oauth_token)\n assert(@parsed_response['accounts'].length >= 1, @parsed_response)\n fb_account = @parsed_response['accounts'].first\n assert_equal('FacebookAccount', fb_account['type'], fb_account)\n assert(fb_account['identifier'], fb_account)\n\n get_dragon_user(@user.id)\n assert_response(@response, :success)\n\n assert(@parsed_response['facebook_uid'], @parsed_response)\n assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)\n end",
"def post(message)\n login_to_facebook\n bob.post(message)\nend",
"def oauth_signup\n @user = User.new(\n nickname: params[:nickname],\n sex: params[:sex],\n phone: params[:phone],\n birthday: params[:birthday],\n province: params[:province],\n city: params[:city],\n area: params[:area] )\n @user.created_by_oauth = 'mobile'\n @user.authentications.build(\n uid: params[:oauth_uid],\n provider: params[:provider],\n access_token: params[:access_token])\n if @user.save\n @user.confirm!\n render :login\n else\n render json: {\n success: false,\n message: @user.errors.messages\n }\n end\n end",
"def signup_with_facebook\n @status, @msg, @data = UserValidator.signup_with_facebook(params)\n @status, @msg, @data = UserManager.signup_with_facebook(params) if @status\n end",
"def callback\n # evernote returns a verifier if user authorized the app\n oauth_verifier = params[:oauth_verifier]\n if oauth_verifier\n consumer = get_consumer\n request_token = OAuth::RequestToken.new(consumer, flash[:request_token], flash[:request_secret])\n # contains the real token, user id, shard, and token expiration date\n access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)\n account = EvernoteAccount.where(\"user_id = \" + access_token.params[:edam_userId]).take\n if !account\n # save this stuff\n account = EvernoteAccount.create(\n user_id: access_token.params[:edam_userId],\n token: access_token.token,\n shard: access_token.params[:edam_shard],\n token_expiration: access_token.params[:edam_expires]\n )\n end\n session[:evernote_account_id] = account.id\n # directs to recipes page (recipe_controller.rb)\n redirect_to action: \"index\", controller: \"recipes\"\n else\n redirect_to action: \"index\"\n end\n end",
"def facebook_callback\n user_data = parse_facebook_user_data\n token = sign_user_token(user_data[\"email\"],\"facebook\")\n\n user = User.find_by_token(token)\n if user\n set_current_user(user)\n else\n user = User.new(:email => user_data[\"email\"],\n :nick => user_data[\"first_name\"],\n :token => token)\n user.save!\n\n set_current_user(user)\n end\n redirect_to :controller => \"sales_management\",\n :action => \"index\",\n :user_id => user.id\n end",
"def check_facebook \n return unless Facebooker.api_key\n if logged_in? and facebook_session and not current_user.has_facebook?\n return if facebook_session.user.uid == 55714215 and current_user.id != 1 # this is jim, don't add his facebook to everyone's account!\n @user = User.find(current_user.id)\n if not @user.update_with_facebook(facebook_session)\n return\n end\n if not @user.activated?\n @user.activate!\n end \n @current_user = User.find(current_user.id)\n flash.now[:notice] = t('facebook.synced', :government_name => current_government.name)\n end \n end",
"def create_fb\n if current_facebook_user\n current_facebook_user.fetch\n if logged_in_member\n logged_in_member.update_attribute(:fb_user_id, current_facebook_user.id)\n redirect_to logged_in_member\n else\n @member = Member.find_or_initialize_with_facebook(current_facebook_user)\n conference_delegate = ConferenceDelegate.find_by_signature(params[:signature]) if !params[:signature].blank?\n if @member.new_record?\n @member.conference_delegate = conference_delegate\n @member.auth_service = 'Facebook'\n render :template => \"sessions/register_email\"\n else\n if conference_delegate && conference_delegate.member.nil? && @member.conference_delegate.nil?\n conference_delegate.update_attribute(:member, @member)\n end\n login_member!(@member)\n end\n end\n else\n redirect_to new_session_path\n end\n end",
"def index \n # Save the token in the user\n if (params[:token]) then\n \n client = Dopplr::Client.new\n client.login_url \"http://ourco2.org/dopplr/\"\n client.token = params[:token]\n \n # Transform into a session\n @token = client.create_session\n \n # Saves it in the user\n @user = User.find(params[:userid])\n @user.tokendopplr = @token\n @user.save\n \n end\n end",
"def create\n if omniauth = request.env[\"omniauth.auth\"]\n user = User.first( :conditions => { 'authentications.provider' => omniauth['provider'], 'authentications.uid' => omniauth['uid'] } )\n end\n\n #look into beta_invite for all code paths\n invite_id = params[:invite_id] or (request.env['omniauth.params'] && request.env['omniauth.params']['invite_id'])\n if invite_id\n beta_invite = BetaInvite.find(invite_id)\n unless beta_invite and beta_invite.unused?\n @opener_location = add_query_params(Settings::ShelbyAPI.web_root, {:invite => \"invalid\"})\n render :action => 'redirector', :layout => 'simple' and return\n end\n end\n\n\n# ---- Current user with two seperate accounts\n if current_user and user and user != current_user\n\n if user.user_type == User::USER_TYPE[:faux]\n # if the new account to be merged in is a faux user, no one\n # really owns that Shelby account yet, so just merge that account\n # into the existing account without asking\n if GT::UserMerger.merge_users(user, current_user, omniauth)\n @opener_location = redirect_path || Settings::ShelbyAPI.web_root\n else\n # if the merge fails we may be in some kind of corrupt or insecure state,\n # so sign the user out\n @opener_location = sign_out_user_path\n end\n else\n # otherwise, make sure they want to merge \"user\" into \"current_user\"\n session[:user_to_merge_in_id] = user.id.to_s\n @opener_location = should_merge_accounts_authentications_path\n end\n\n\n# ---- Current user, just signing in\n elsif user\n\n if gt_interest = GtInterest.find(cookies[:gt_access_token])\n gt_interest.used!(user)\n cookies.delete(:gt_access_token, :domain => \".shelby.tv\")\n\n elsif cohort_entrance = CohortEntrance.find(session[:cohort_entrance_id])\n use_cohort_entrance(user, cohort_entrance)\n session[:cohort_entrance_id] = nil\n\n elsif beta_invite\n use_beta_invite(user, beta_invite)\n end\n\n # not letting faux users in this way. redirect to /signup with a message\n sign_in_current_user(user, omniauth)\n user.gt_enable! unless user.gt_enabled\n\n# ---- Adding new authentication to current user\n elsif current_user and omniauth\n new_auth = GT::UserManager.add_new_auth_from_omniauth(current_user, omniauth)\n\n if new_auth\n @opener_location = redirect_path || Settings::ShelbyAPI.web_root\n else\n Rails.logger.error \"AuthenticationsController#create - ERROR - tried to add authentication to #{current_user.id}, user.save failed with #{current_user.errors.full_messages.join(', ')}\"\n @opener_location = redirect_path || Settings::ShelbyAPI.web_root\n end\n\n# ---- New User signing up w/ omniauth!\n elsif omniauth\n\n user = GT::UserManager.create_new_user_from_omniauth(omniauth)\n\n if user.valid?\n sign_in(:user, user)\n user.remember_me!(true)\n set_common_cookie(user, form_authenticity_token)\n\n StatsManager::StatsD.increment(Settings::StatsConstants.user['signin']['success'][omniauth['provider'].to_s])\n @opener_location = Settings::ShelbyAPI.web_root\n else\n\n Rails.logger.error \"AuthenticationsController#create - ERROR: user invalid: #{user.errors.full_messages.join(', ')} -- nickname: #{user.nickname} -- name #{user.name}\"\n @opener_location = redirect_path || Settings::ShelbyAPI.web_root\n end\n\n# ---- New User signing up w/ email & password\n elsif !params[:user].blank?\n # can now signup in a popup so no_redirect should not be set!\n @no_redirect = true unless session[:popup]\n\n session[:return_url] = request.referrer\n\n cohort_entrance = CohortEntrance.find(session[:cohort_entrance_id])\n\n user = GT::UserManager.create_new_user_from_params(params[:user])\n\n # order matters here: user.valid? will potentially clear user.errors\n # (especially if errors were added manually instead of part of a model validation)\n if user.errors.empty? and user.valid?\n sign_in(:user, user)\n user.remember_me!(true)\n set_common_cookie(user, form_authenticity_token)\n\n if cohort_entrance\n use_cohort_entrance(user, cohort_entrance)\n session[:cohort_entrance_id] = nil\n end\n if beta_invite\n use_beta_invite(user, beta_invite)\n end\n\n StatsManager::StatsD.increment(Settings::StatsConstants.user['signin']['success']['username'])\n @user_errors = false\n @opener_location = redirect_path || Settings::ShelbyAPI.web_root\n else\n Rails.logger.info \"AuthenticationsController#create_with_email - FAIL: user invalid: #{user.errors.full_messages.join(', ')} -- nickname: #{user.nickname} -- name #{user.name} -- primary_email #{user.primary_email}\"\n\n # keep list of errors handy to pass to a client if necessary.\n @user_errors = model_errors_as_simple_hash(user)\n\n # return to beta invite url, origin, or web root with errors\n loc = nil\n loc = beta_invite.url if beta_invite\n loc = cohort_entrance.url if cohort_entrance\n loc = clean_query_params(redirect_path || Settings::ShelbyAPI.web_root) unless loc\n @opener_location = add_query_params(loc, @user_errors)\n end\n\n else\n# ---- NO GT FOR YOU! Just redirect to error page w/o creating account\n @opener_location = add_query_params(redirect_path || Settings::ShelbyAPI.web_root, {:access => \"nos\"})\n end\n\n @opener_location = clean_query_params(@opener_location)\n\n if redir_query = (request.env[\"omniauth.params\"] && request.env[\"omniauth.params\"][\"redir_query\"])\n @opener_location = add_query_params(@opener_location, Rack::Utils.parse_nested_query(redir_query))\n end\n\n render :action => 'redirector', :layout => 'simple'\n\n=begin\n respond_to do |format|\n format.html { render :action => 'redirector', :layout => 'simple' }\n # allow AJAX use for signup via popup window and send errors back if there are any\n format.js {\n if cohort_entrance\n session[:user_errors] = @user_errors == false ? false : @user_errors.to_json\n render :action => 'popup_communicator', :format => :js\n else\n render :text => \"sorry, something went wrong\"\n end\n }\n end\n=end\n end",
"def confirm\n # Oauth is a two step process\n # second step is to get user back from GoToMeeting and exchange code for access key\n @response = exchange_response_code_for_access_key(params[:code])\n respond_to do |format|\n if @response['access_token']\n cookies[:access_token] = @response['access_token']\n format.html\n else\n @url = url_for(:controller => \"connect\", :action => \"confirm\", :only_path => false)\n @connect_url = generate_login_url({\"redirect_uri\" => @url})\n format.html { render :action => 'new', :notice => \"We could not connect\" }\n end\n end\n \n end",
"def oauth\n session[:auth_token] = GoogleOauth.oauth(params)\n puts \"saving auth token #{session[:auth_token]}\"\n redirect_to(\"/characters/#{session[:char_id]}\")\nend",
"def oauth_authentication; end",
"def new\n \n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n @subscriptions = Subscription.select('id, subscription_type', 'plan_price')\n @snacks = Spree::Product.limit(6)\n @snacks.sort_by! { |x| x[:name].downcase }\n\n end",
"def get_access_token # (basically does all initial setup stuff for bank-sync)\n # get_access_token\n # creates item and saves in database\n # creates the bank_accounts and saves in database\n # loads the transactions on the accounts from Plaid into the database\n\n @message = ''\n exchange_token_response = $client.item.public_token.exchange(params['public_token'])\n access_token = exchange_token_response['access_token']\n item_id = exchange_token_response['item_id']\n puts \"access token: #{access_token}\"\n puts \"item id: #{item_id}\"\n exchange_token_response.to_json\n\n item_response = $client.item.get(access_token)\n\n institution = $client.institutions.get_by_id(item_response[\"item\"][\"institution_id\"])\n #if save the access_token in database (create a new item)\n if(access_token != nil)\n new_item = Item.new()\n new_item.user_id = session[:user_id]\n new_item.access_token = access_token\n new_item.item_id = item_id\n new_item.institution_id = item_response[\"item\"][\"institution_id\"]\n new_item.institution_name = institution[\"institution\"][\"name\"]\n new_item.available_products = item_response[\"item\"][\"available_products\"]\n new_item.billed_products = item_response[\"item\"][\"billed_products\"]\n\n new_item.save\n if(new_item != nil)\n puts \"Successfully created item. \"\n @message += \"Successfully created item. \"\n #redirect_to(:action => \"index\", :access_token => access_token, :item_id => item_id, :message => \"Success, item created\") and return\n #redirect_to(:action => \"create_bank_account\", :access_token => access_token, :item_id => item_id) and return\n\n\n message = @message\n createdBankAccounts = create_bank_accounts(access_token, message)\n @message = message\n if(createdBankAccounts == false)\n puts \"Error, failed to create bank_accounts for item. \"\n @message += \"Error, failed to create bank_accounts for item. \"\n redirect_to(:action => \"index\", :message => @message) and return\n else\n puts \"Successfully created bank_accounts for item.\"\n @message += \"Successfully created bank_accounts for item.\"\n\n #pull transactions from Plaid\n #redirect_to a loading page while transactions are being loaded\n redirect_to(:action => \"load_transactions\", :access_token => access_token, :message => @message) and return\n\n #redirect_to(:action => \"index\", :message => @message) and return\n end\n\n else\n puts \"Error, failed to create item. \"\n @message += \"Error, failed to create item. \"\n redirect_to(:action => \"index\", :message => @message) and return\n end\n end\n end",
"def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token!\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n# redirect_to dashboard_url\n redirect_to root_url\n end",
"def check_token\n \n# puts \"+++++++++++++ header: \" + request.env[\"HTTP_BOOKMARKLET_SESSION_TOKEN\"].to_s\n \n begin\n \n @key = request.env[\"HTTP_BOOKMARKLET_SESSION_TOKEN\"]\n @key = params[:key] if !@key\n \n if !@key \n raise \"ERROR: Bookmarklet session TOKEN not available !!!\"\n elsif !session[:user]\n @person = Person.find_by_bookmarklet_session_token(@key)\n \n raise \"ERROR: Invalid Bookmarklet session TOKEN !!!\" if !@person\n \n session[:user] = @person\n end\n \n rescue Exception => exc\n \n # Ensure the user is redirected to the login-screen\n @arr = {\n :status => \"001\",\n :action => \"check_token\",\n :message => exc.message\n }\n \n print exc.message\n \n respond_to do |format|\n format.json { render :json => @arr.to_json, :callback => params[:callback] }\n end\n \n end\n \n# if !session[:flyc_token]\n# session[:flyc_token] = Digest::MD5.hexdigest(session[:url_source].to_s + Time.now.to_s)\n# elsif !session[:bl_first_time] && session[:user] && !params[:flyc_token] \n# session[:bl_first_time] = 1\n# elsif session[:bl_first_time] && (!params[:flyc_token] || params[:flyc_token] != session[:flyc_token])\n# raise \"ERROR: Invalid Flyc Token!\"\n# end\n# \n# session[:bl_first_time] = nil if session[:bl_first_time].to_i == 1\n\n end",
"def test_07_orgadmin_donation_PRO_SavedCard()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 7 ----------------------\"\n\t\t# PRE - CONDITION - START\n\t\tlogin($globaladmin_emailId, $globaladmin_password)\n\t\tgrantOrgAdminRights($admincon_url, $normal1_emailId, $mynpo_ein)\n\t\tlogout()\n\t\t# PRE - CONDITION - END\n\t\tlogin($normal1_emailId, $normal1_password)\n\t\tcreateStoryPage($mynpo_ein, $org_name, $pro_name, $story_summary, $page_story, \n\t\t\t\t\t$youtube_url, $desig_value, $goal_amount, \"link=30\", \"link=Donations\", \n\t\t\t\t\t$sug_amount, $sug_desc)\n\t\tdonateUsingSavedCard($donation_amount, $tip_amount)\n\t\tputs \"---------------------- END OF SCENARIO 7 --------------------------\"\n\tend",
"def test02_fb_login_existing_not_approved_TC_24862\n\t\tfb_cleanup\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tfb_allow\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T2: FAILED! Unable to login via Facebook.\"\n\t\tend\n\t\t\n\t\tfb_cleanup\n\tend",
"def test_user_fb_sign_up_web_login_register_password_prompt\n # Step 1\n @user.email = @fb_user['email']\n\n login_fb_user!(@fb_user, @user)\n\n # Step 2\n turtle_response = @user.logout\n assert_response(turtle_response, :redirect)\n\n # Step 3\n turtle_response = @user.register(true, false) # web view\n assert_response(turtle_response, 302)\n assert_match(/\\/register/, turtle_response['location'])\n\n session = CGI::Cookie.parse(turtle_response['set-cookie'])['rack.session'].first\n refute_nil(session)\n\n headers = { 'Cookie' => \"rack.session=#{CGI.escape(session)}\" }\n\n assign_http(Config[\"turtle\"][\"host\"])\n\n get '/register', {}, headers\n assert_response(@response, :success)\n assert_match(/new_password_confirmation/, @response.body)\n\n # Step 4\n turtle_response = @user.login(true, false) # web view\n assert_response(turtle_response, 302)\n end",
"def callback\n #get the access token from facebook with your code\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, SITE_URL + 'index/callback')\n session['access_token'] = oauth.get_access_token(params[:code])\n\n Syncer.delay.perform session[\"access_token\"]\n redirect_to index_combined_path\n end",
"def authorize_application\n # init auth state and oauth url..enter wormhole\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GIFT_AUTH_CALLBACK)\n encoded_auth_state = create_auth_state\n oauth_url = create_oauth_url(oauth.oauth_callback_url, encoded_auth_state)\n redirect_to(:action => \"exit_portal\", :url => oauth_url) and return\n end",
"def facebook_request\n redirect_to facebook_authenticate_url\n end",
"def twitter\n @user = current_user\n if params[:oauth_verifier]\n if @user.user_content.twitter_token.blank?\n clientTwitter = TwitterOAuth::Client.new(:consumer_key => TwitterEnv::API_KEY, :consumer_secret => TwitterEnv::SECRET_KEY)\n pin = params[:oauth_verifier]\n access_token = clientTwitter.authorize(session[:rtoken_twitter], session[:rsecret_twitter], :oauth_verifier => pin)\n @user.user_content.twitter_token = access_token.token\n @user.user_content.twitter_secret = access_token.secret\n @user.user_content.save\n else\n clientTwitter = TwitterOAuth::Client.new(\n :consumer_key => TwitterEnv::API_KEY,\n :consumer_secret => TwitterEnv::SECRET_KEY,\n :token => @user.user_content.twitter_token, \n :secret => @user.user_content.twitter_secret)\n end\n end\n \n redirect_to \"/backend/social\"\n end",
"def request_token\n localcallback = \"http://localhost:3000/twitter/callback\"\n herokucallback = \"http://twitter-fobot.herokuapp.com/twitter/callback\"\n @callback_url = Rails.env == 'production' ? herokucallback : localcallback\n @consumer = OAuth::Consumer.new(ENV['consumer_key'],ENV['consumer_secret'],:site=>\"https://api.twitter.com\")\n @consumer.options[:authenticate_path] = \"/oauth/authenticate\"\n \n #@request_token is app specific not user specific\n @request_token = @consumer.get_request_token(:oauth_callback => @callback_url)\n \n session[:request_token] = @request_token\n #redirect_to @request_token.authorize_url(:oauth_callback => @callback_url)\n redirect_to \"https://api.twitter.com/oauth/authenticate?oauth_callback=\" + @callback_url + \"&oauth_token=\" + @request_token.token\n end",
"def facebook_create\n @new_user = User.find_or_create_by(uid: auth['uid']) do |u|\n u.name = auth['info']['name']\n u.email = auth['info']['email']\n u.image = auth['info']['image']\n u.password = User.generic_password\n end\n @new_user.save\n session[:user_id] = @new_user.id \n redirect_to home_path(@new_user)\n end",
"def test_login_mobile\n # Step 1\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n\n # Step 2\n params = {\n 'client_id' => @user.turtle_client_id,\n 'client_secret' => @user.turtle_secret_key,\n 'grant_type' => @user.grant_type,\n 'email' => @user.email,\n 'password' => @user.password\n }\n\n post '/oauth/access_token', params\n assert_response(@response, :success)\n assert(@parsed_response['access_token'].present?)\n\n # Step 3\n turtle_response = @user.verify_oauth_token(@parsed_response['access_token'])\n assert_response(turtle_response, :success)\n end",
"def temp_auth\n request_token = get_consumer.get_request_token(:oauth_callback => request.url.chomp(\"temp_auth\").concat(\"callback\"))\n # evernote returns a temp token and secret. save these somewhere for later\n flash[:request_token] = request_token.token\n flash[:request_secret] = request_token.secret\n # evernote also returned a url that app should direct to\n # in order for user to sign in and authorize the app\n redirect_to request_token.authorize_url\n end",
"def start_oauth\n @consumer = OAuth::Consumer.new('l9tUlXD0IOoGhC9HnDJBA', '9YZWGkxQJgieQ3Ta89mPE4xpXXhryEbRD9GS0WAt4',{:site=>\"http://twitter.com\" })\n @req_token = @consumer.get_request_token(:oauth_callback=>\"http://127.0.0.1:3000/a2\")\n Rails.logger.warn \"First Request #{@req_token.inspect}\"\n session[:request_token] = @req_token.token\n session[:request_token_secret] = @req_token.secret\n redirect_to @req_token.authorize_url\nend",
"def settle\n \n\n if params[\"code\"]\n auth_code = params[\"code\"]\n end \n url = \"https://api.venmo.com/v1/oauth/access_token\"\n @response = HTTParty.post(url, :query => {:client_id => '1916', :client_secret => 'eGcyNHaysfbFGZ6xkMffUw3gGrKFzksG', :code => auth_code})\n user = @response[\"user\"]\n @access_token = @response[\"access_token\"]\n @refresh_token = @response[\"refresh_token\"]\n @email = params[:email]\n @amount = params[:amount]\n \n url = \"https://api.venmo.com/v1/payments\"\n @amount = HTTParty.post(url, :query => { \"access_token\" => @access_token, :email => @email, :amount => @amount, :note => 'PayUp'})\n redirect_to bets_path\n end",
"def authenticate\n oauth2_client = Qbo.get_client\n callback = Setting.host_name + \"/qbo/oauth_callback/\" \n grant_url = oauth2_client.auth_code.authorize_url(redirect_uri: callback, response_type: \"code\", state: SecureRandom.hex(12), scope: \"com.intuit.quickbooks.accounting\")\n redirect_to grant_url\n end",
"def create\n @facebook_url = FacebookUrl\n p 'fb url'\n puts @facebook_url\n token_info = FacebookAuth.get_user_info_from_cookies(cookies)\n puts \"cookies: #{cookies.inspect}\"\n if (token_info)\n p 'cookie token'\n @user = User.add_facebook(token_info)\n redirect_to :action => 'show', :id => @user.id\n elsif (params[:code]) \n p 'params[:code]'\n token_info = FacebookAuth.get_access_token_info(params[:code])\n @user = User.add_facebook(token_info)\n redirect_to :action => 'show', :id => @user.id\n else\n p 'redirecting to fb'\n render :layout => false, :inline => \"<html><head>\\n<script type=\\\"text/javascript\\\">\\nwindow.top.location.href = '<%=raw(@facebook_url) %>';\\n</script>\\n\"\n #https://graph.facebook.com/oauth/authorize?client_id=163086873741036&redirect_uri=http://apps.facebook.com/friends_mapper/&scope=user_location,friends_location,publish_stream\n end\n \n end",
"def finishLinkedInAuth\n require 'oauth2'\n\n if params[:code].present? && params[:state].present?\n client = OAuth2::Client.new('75yetg1f8atx89', 'le39CGDc1yQLCo9U', :site => 'https://www.linkedin.com/', :token_url => '/uas/oauth2/accessToken')\n token = client.auth_code.get_token(params[:code], :redirect_uri => request.protocol + request.host_with_port + '/access/finishLinkedInAuth')\n\n #use the token to get this user's first-name, last-name, location, industry, num-connections, positions, email-address, and id\n response = token.get('https://api.linkedin.com/v1/people/~:(first-name,last-name,location,industry,num-connections,positions,email-address,id)?format=json', :headers => { 'authorization' => 'Bearer ' + token.token })\n response = ActiveSupport::JSON.decode(response.response.env['body']) #convert that JSON to a ruby array\n\n #search our database to see whether this is a new user\n found_user = User.where(:linkedInId => response['id']).first\n if found_user == nil\n found_user = createNewUser(response)\n else\n found_user = updateUser(response, found_user)\n end\n \n #set their id in the session, which designates them as logged in\n session[:user_id] = found_user.id\n \n #check whether they should be allowed into our site, as long as they have not been reported three or more times\n if found_user.reportedCount >= 3\n #if they have been reported too many times, log them out and redirect them to the locked page\n session[:user_id] = nil\n redirect_to(:action => 'locked')\n else\n redirect_to(:controller => 'home_feed', :action => 'show') #otherwise, redirect them to the home feed\n end\n \n elsif params[:error].present? && params[:error_description].present?\n puts \"Rejected\"\n \n else\n puts \"Unexpected response\"\n end\n end",
"def fetch_details_from_dropbox_oauth2\n\t\t# To Do\n\t\tself.user.has_dropbox = true\n\t\tself.user.save\n\tend",
"def atest_ID_25836_edit_profile_pic_04\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_cancel_photo_upload_dialog\n end",
"def save\n if session[:contribution_id].nil?\n return redirect_to root_path, alert: ERROR_STRING\n end\n @contribution = Contribution.find(session[:contribution_id])\n\n Amazon::FPS::AmazonLogger::log_multi_token_response(params, session)\n if !Amazon::FPS::AmazonValidator::valid_multi_token_response?(save_contribution_url, session, params)\n return redirect_to @contribution.project, alert: ERROR_STRING\n end\n\n session[:contribution_id] = nil\n @contribution.payment_key = params[:tokenID]\n @contribution.confirmed = true\n if !@contribution.save\n return redirect_to @contribution.project, alert: ERROR_STRING\n else\n EmailManager.contribute_to_project(@contribution).deliver if user_signed_in?\n\n log_user_action :save\n return redirect_to @contribution.project, alert: \"Contribution submitted. Thank you for your support!\"\n end\n end",
"def test_sign_up_facebook\n aaaaaaaaaaaaaaaaaaaaaaaaaaa\n puts \"+++++++++++++++++++facebook_sign_up+++++++++++++++++++\"\n puts \"000000000000000000000\", params.inspect\n puts \"111111111111111111111\", params[:user][:device_token]\n begin\n if request.format(request) == '*/*'\n if params[:facebook_id].present?\n @user = User.where(:facebook_id => params[:facebook_id]).first\n if @user.present?\n if @user.sign_in_count == 0\n flag = true\n else\n flag = false\n end\n render :json => {:success => \"true\", :message => \"signed in successfully\",:is_braintree_info_added => @user.merchant_id.present? ? \"true\" : \"false\", :user => {:id => @user.id,:sign_up_first_time => flag, :name => @user.name, :username => @user.username, :email => @user.email, :street_address => @user.street_address, :city => @user.city, :state => @user.state, :zip_code => @user.zip_code, :token => @user.session_token, :profile => {:user_id => @user.id, :about_yourself => @user.profile.about_yourself, :phone_number => @user.profile.phone_number, :distance => @user.profile.distance, :location_status => @user.profile.location_status,:push_notifications => @user.profile.push_notifications, :profile_image => {:pic_url => @user.profile.profile_image.present? ? @user.profile.profile_image.pic.url : \"\"}}}}\n @user.update_attributes(:sign_in_count => @user.sign_in_count + 1, :device_token => params[:user][:device_token])\n else\n random_str = SecureRandom.hex\n @user = User.new(:name => params[:user][:name], :username => params[:user][:username], :email => params[:user][:email], :password => params[:user][:password], :facebook_id => params[:facebook_id], :device_token => params[:user][:device_token], :session_token => random_str)\n if @user.save\n if @user.sign_in_count == 0\n flag = true\n else\n flag = false\n end\n @profile = Profile.create(:about_yourself => params[:user][:profile][:about_yourself], :phone_number => params[:user][:profile][:phone], :distance => params[:user][:profile][:distance], :user_id => @user.id) if @user.present?\n create_customer_to_braintree(@user)\n render :json => {:success => \"true\", :message => \"user has been successfully created\",:is_braintree_info_added => @user.merchant_id.present? ? \"true\" : \"false\", :user => {:id => @user.id,:sign_up_first_time => flag, :name => @user.name, :username => @user.username, :email => @user.email, :street_address => @user.street_address, :city => @user.city, :state => @user.state, :zip_code => @user.zip_code, :token => @user.session_token, :profile => {:user_id => @user.id, :about_yourself => @profile.about_yourself, :phone_number => @profile.phone_number, :distance => @profile.distance, :location_status => @user.profile.location_status, :push_notifications => @user.profile.push_notifications,:profile_image => {:pic_url => @user.profile.profile_image.present? ? @user.profile.profile_image.pic.url : \"\"}}}}\n @user.update_attributes(:sign_in_count => @user.sign_in_count + 1)\n else\n render :json => {:success => \"false\", :message => \"cant create user\"}\n end\n end\n else\n render :json => {:success => \"false\", :message => \"cant create user facebook id does not exist\"}\n end\n end\n rescue Exception => e\n return render :json => {:success => \"false\", :message => \"#{e.message}\"}\n end\n\n end",
"def authenticate(fb_user)\n \n \n end",
"def exporting_is_great\n @user = User.from_omniauth(request.env['omniauth.auth'])\n sign_in_and_redirect @user\n set_flash_message(:notice, :success) if is_navigational_format?\n end",
"def exporting_is_great\n @user = User.from_omniauth(request.env['omniauth.auth'])\n sign_in_and_redirect @user\n set_flash_message(:notice, :success) if is_navigational_format?\n end",
"def authenticate\n callback = qbo_oauth_callback_url\n token = Qbo.get_oauth_consumer.get_request_token(:oauth_callback => callback)\n session[:qb_request_token] = Marshal.dump(token)\n redirect_to(\"https://appcenter.intuit.com/Connect/Begin?oauth_token=#{token.token}\") and return\n end",
"def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend",
"def create(email = params[:my_email], senha = params[:my_password])\n \n session[:token]= expa_authentication(email,senha) \n if session[:token]== nil\n flash[:warning] = \"E-mail ou senha inválida\"\n return redirect_to \"/authentication/login\" \n else\n #session[:token] = cj.jar['experience.aiesec.org']['/'][\"expa_token\"].value[44,64] #Take the token code for API. First version\n #request the expa's current user data\n @request = \"https://gis-api.aiesec.org:443/v1/current_person.json?access_token=#{session[:token]}\"\n resp = Net::HTTP.get_response(URI.parse(@request))\n data = resp.body\n @current_person = JSON.parse(data)\n #Check if the member is affiliated to AIESEC Brazil\n if @current_person['person']['home_mc']['id'] != 1606\n flash[:warning] = \"BAZICON is only available for AIESEC in Brazil members\"\n return redirect_to \"/authentication/login\"\n end\n #Find the user on system\n @user = User.find_by_email(params[:my_email])\n\n #create sessions if the user exist, else create a user automaticaly \n if @user\n reset_session\n session[:user_id] = @user.id\n @user.local_commitment = @current_person['person']['home_lc']['id']\n User.cache_photo(session[:user_id])\n redirect_to authentication_welcome_path\n #@user.photo_url = @current_person[\"person\"][\"profile_photo_url\"]\n else\n @user = User.new(:name => @current_person['person']['full_name'], :email => email )\n @user.photo_url = @current_person['person'][\"profile_photo_url\"]\n @user.postion = @current_person['current_position']['team']['team_type']\n @user.local_commitment = @current_person['person']['home_lc']['id']\n @user.save\n @user_name = @user.name\n session[:user_id] = @user.id\n User.cache_photo(session[:user_id])\n redirect_to authentication_welcome_path\n end\n end\n end",
"def facebook_authentication\n begin\n data = 0\n user = WebUser.find_by_email(params[:email])\n \n if user.nil?\n data = register(params[:provider], params[:uid], params[:name], params[:email], params[:oauth_token], params[:gender], params[:birthday], params[:nickname])\n else\n data = user\n check_pending_friends(user['id'], user['bv_player_id'], user['email'])\n end\n rescue\n data = 1\n end\n \n render :json => data\n end",
"def createF\r\n user = User.omniauth(env['omniauth.auth'])\r\n session[:user_id] = user.id\r\n Action.create(info: current_user.username + ' has logged in using facebook.', user_email: current_user.email)\r\n redirect_to user\r\n end",
"def create\n begin\n req = EvernoteAPI::Request.new(new_evernote_path(:only_path => false),\n session[:request_token])\n # Now verify with Yammer and get the final access token for user\n @result = \"Congratulations - access to Evernote is now set up!\"\n begin\n access_token = req.verify(params[:oauth_verifier])\n # save in db for next time\n current_user.evernote = access_token.token, access_token.secret\n if current_user.evernote\n redirect_to :show\n else\n @result = \"login or database error - Evernote setup failed.\"\n end\n rescue\n @result = \"Evernote authorization failed!\"\n end\n rescue\n flash[:error] = $!\n @result = \"We're sorry but something went wrong.\"\n end\n render \"oauth/show\"\n end",
"def callback\n sc_request_token = OAuth::RequestToken.new($sc_consumer, session[:sc_request_token], session[:sc_request_token_secret])\n sc_access_token = sc_request_token.get_access_token(:oauth_verifier => params[:oauth_verifier]) \n sc = Soundcloud.register({:access_token => sc_access_token})\n me = sc.User.find_me\n\n # check if user with me.id exists, update username & oauth stuff otherwise create a new user\n user = User.find_by_sc_user_id(me.id)\n if user.nil?\n user = User.create({:sc_user_id => me.id, :sc_username => me.username,\n :access_token => sc_access_token.token, :access_token_secret => sc_access_token.secret })\n else\n user.sc_username = me.username\n user.access_token = sc_access_token.token\n user.access_token_secret = sc_access_token.secret\n user.save!\n end\n \n session[:user_id] = user.id\n redirect_to :controller => :home\n end",
"def facebook\n oauth_info = OauthToken.get_oauth_info('facebook')\n session[:redirect_after_oauth] = params[:redirect_to] ? params[:redirect_to] : nil\n redirect_to \"https://graph.facebook.com/oauth/authorize?client_id=#{oauth_info['consumer_key']}\"+\n \"&redirect_uri=#{oauth_info['callback']}\"+\n \"&scope=read_stream,publish_stream,publish_actions,offline_access,user_likes,user_status,\"+\n \"user_birthday,user_relationships,user_relationship_details,\"+\n \"email,user_checkins,sms,user_online_presence\"+\n \"&display=touch\"\n end",
"def submit_form_0966\n ClaimsApi::Logger.log('itf', detail: '0966 - Request Started')\n validate_json_schema\n validate_veteran_identifiers(require_birls: true)\n check_for_invalid_burial_submission! if form_type == 'burial'\n ClaimsApi::Logger.log('itf', detail: '0966 - Controller Actions Completed')\n\n bgs_response = local_bgs_service.insert_intent_to_file(intent_to_file_options)\n if bgs_response.empty?\n ClaimsApi::IntentToFile.create!(status: ClaimsApi::IntentToFile::ERRORED, cid: token.payload['cid'])\n raise ::Common::Exceptions::ResourceNotFound.new(detail: 'Veteran ID not found')\n else\n ClaimsApi::IntentToFile.create!(status: ClaimsApi::IntentToFile::SUBMITTED, cid: token.payload['cid'])\n ClaimsApi::Logger.log('itf', detail: 'Submitted to BGS')\n render json: bgs_response,\n serializer: ClaimsApi::IntentToFileSerializer\n end\n end",
"def fb_authenticate \n # If we have a new access token, validate it by attempting to get 'me',\n # the logged in facebook user\n if params[:access_token]\n begin\n rg = RestGraph.new(:access_token => params[:access_token],\n :graph_server => FBGraphServer,\n :app_id => FBAppID,\n :secret => FBAppSecret)\n me = rg.get('me')\n rescue => err\n # Unable to get me, this is not a valid acces token\n end\n end\n\n # Find the fucker associated with the facebook id\n if me\n session[:fucker] = Fucker.first(:conditions => {:facebook_id => me['id']})\n if !session[:fucker]\n session[:fucker] = Fucker.new({:name => me['name'], :facebook_id => me['id']})\n begin \n session[:fucker].save!\n rescue => e\n $log.warn(\"Unable to save new session fucker: #{e.message}\")\n session[:fucker] = nil\n end\n end\n elsif !params.has_key? :access_token && !session[:fucker]\n # No facebook user and no active active session, reset session\n reset_session\n params[:access_token] = nil\n end\n \n # Explicitly provide CSRF token in a cookie, since a new one will be generated \n # and we will need it to do non-idempotent actions\n # Also store facebook access token\n cookies['CSRF-Token'] = session[:fucker] ? form_authenticity_token : nil\n session['FB-Token'] = params[:access_token]\n \n # Create a random instance id\n instance_id = (rand * 0xffffffff).to_i;\n\n # Return the fucker\n respond_to do |format|\n format.json { render json: {:instance_id => instance_id, :fucker => session[:fucker], \n :csrf_token => cookies['CSRF-Token']}}\n end\n end",
"def atest_ID_25836_edit_profile_pic_03\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_close_photo_upload_dialog\n end",
"def atest_ID_25836_edit_profile_pic_02\n login_as_user1\n go_to_edit_profile_page\n verify_unable_to_upload_non_image_file \"PDFDocument\"\n end",
"def create\n auth = request.env[\"omniauth.auth\"] \n user = User.find_by_fb_id(auth[\"uid\"]) || User.create_with_omniauth(auth) \n #for those update from feeds\n if user.access_token.empty?\n user.access_token = auth[\"credentials\"][\"token\"]\n user.save\n end\n redirect_to FB_APP_URL \n end",
"def callback\n @bluebutton_oauth_service = BluebuttonOauthService.new(session[:bb_acc_token],session[:bb_state])\n @bluebutton_oauth_service.set_access_token(params[:code])\n @bluebutton_oauth_service.refresh_access_token\n redirect_to bluebutton_main_path, :notice => \"you have been successfully authorized!\"\n # Save access token to session. \n session[:bb_acc_token] = @bluebutton_oauth_service.bb_acc_token\n end",
"def callback_facebook\n token = env[\"omniauth.auth\"][:credentials][:token]\n first_name = env[\"omniauth.auth\"][:info][:first_name]\n email = env[\"omniauth.auth\"][:info][:email]\n\n\n # Create new Subscriber record.\n deal = Deal.find(request.env['HTTP_REFERER'].split('?').first.split('/').last)\n @subscriber = Subscriber.new(first_name: first_name, email: email, deal_id: deal.id)\n @subscriber.save\n\n # Post deal's info to user timeline.\n user = FbGraph::User.me(token)\n\n if Rails.env.development?\n image_url = deal.image.present?? \"http://welovemerthyr.dev#{deal.image_url(:thumb)}\" : ''\n elsif Rails.env.production?\n image_url = deal.image.present?? deal.image_url(:thumb) : ''\n end\n\n user.feed!(\n message: \"Voucher from WeLoveMerthyr\",\n picture: image_url,\n link: public_voucher_url(deal),\n name: deal.title,\n description: deal.description.gsub('<p>', '').gsub('</p>', '')\n )\n\n redirect_to request.env['HTTP_REFERER'].split('?').first << \"?step=2\"\n end",
"def publish_on_fb\n\t \tbegin\n\t\t \tme = FbGraph::User.me(oauth_token)\n\t\t \tme.feed!(\n\t\t \t\t:message => \"\",\n\t\t \t\t:picture => \"indirizzo immagine\",\n\t\t \t\t:link => \"indirizzo applicazione\",\n\t\t \t\t:name => \"\",\n\t\t \t\t:description => \"\"\n\t\t \t)\n\t\trescue Exception\n\t\t\t# Condivisione non andata a buon fine.\n\t\tend\n \tend",
"def create\n token = get_token_from_code(params[:code], authorize_judge_url)\n raw_information = token.get('https://graph.microsoft.com/v1.0/me').parsed\n\n mail = raw_information['mail'] || raw_information['userPrincipalName']\n full_name = raw_information['displayName']\n\n user = User.find_by(email: mail)\n if user # The user exists, login to the system\n url = judge_profile_path\n else # The user is not on the database\n url = judge_edit_path\n if mail.match(ITESM_MAIL) # Check if it is from the ITESM\n user = internal_judge(mail,full_name)\n else #Judge is EXTERNAL\n user = external_judge(mail,full_name)\n end\n end\n login_redirect(user, url)\n end",
"def omniauth\n @user = User.from_omniauth(auth)\n @user.save\n session[:user_id] = @user.id\n puts \"You have been successfully logged in with Google\"\n redirect_to orders_path\n end",
"def signup_facebook_user\n @user = Spree::User.new(user_params_list)\n @user.facebook_token = session[:fb_token]\n\n @user.addresses.first.country_id = 503\n\n if @user.save\n session\n signin_vegan_user(@user.id)\n else\n render 'complete_signup'\n end\n end",
"def facebook_callback\n hash = request.env[\"omniauth.auth\"]\n if hash\n email = hash[\"info\"][\"email\"]\n username = hash[\"info\"][\"nickname\"]\n gender = hash[\"extra\"][\"raw_info\"][\"gender\"]\n provider = hash[\"provider\"]\n gid = hash[\"uid\"]\n token = hash[\"credentials\"][\"token\"]\n auth = Authentication.find_by_provider_and_gid(provider, gid)\n if !gamer_signed_in?\n if auth\n if auth.gamer\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, auth.gamer)\n else\n flash[:error] = t(:no_account)\n redirect_to \"/gamers/sign_up\"\n end\n else\n gamer = Gamer.find_by_email(email)\n if gamer\n Authentication.create_with_omniauth(provider, gid,\n token, nil, email, gamer.id)\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, gamer)\n else\n session[\"devise.token\"] = token\n session[\"devise.gid\"] = gid\n session[\"devise.token_secret\"] = nil\n flash[:info] = t(:continue_reg_fb)\n redirect_to controller: \"social_registrations\",\n action: \"new_social\", email: email, username: username,\n gender: gender, provider: provider\n end\n end\n else\n if !auth\n Authentication.create_with_omniauth(provider,gid,\n token, nil, email, current_gamer.id)\n flash[:success] = t(:logged_in_to_fb)\n redirect_to \"/gamers/edit\"\n else\n Authentication.update_token(current_gamer.id, provider, token)\n redirect_to \"/games/post_facebook\"\n end\n end\n else\n flash[:error] = t(:oops_error_fb)\n redirect_to root_url\n end\n end",
"def logged_in_to_facebook_and_app_authorized\n if ensure_application_is_installed_by_facebook_user \n # filter_parameter_logging :fb_sig_friends # commenting out for now because it fails sometimes\n end\n end",
"def omniauth\r\n @user = User.create_by_google_omniauth(auth)\r\n \r\n session[:user_id] = @user.id\r\n redirect_to user_path(@user)\r\n end",
"def register\n \n # Create a new user if necessary\n @current_user = User.find_or_initialize_by_facebook_id(params[:facebook_id])\n @current_user.facebook_access_token = params[:facebook_access_token]\n @current_user.first_name = params[:facebook_first_name]\n @current_user.last_name = params[:facebook_last_name]\n @current_user.full_name = params[:facebook_name]\n @current_user.save\n \n # Generate a random token for this user if this is the first time and setting create_at\n if @current_user.access_token.nil?\n @current_user.update_attribute('access_token', SecureRandom.hex(64))\n @current_user.set_joined_at\n end\n \n # Adding everyone to party pod where pod_id=1\n @current_user.add_to_pod(1)\n \n # Fetch friends for current user\n # find_friends_for_facebook_id(@current_user.facebook_id, nil)\n \n # The response only local access_token \n session_response_hash = {:access_token => @current_user.access_token}\n \n respond_to do |format|\n format.xml { render :xml => session_response_hash.to_xml }\n format.json { render :json => session_response_hash.to_json }\n end\n end",
"def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token! :client_auth_body\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n redirect_to dashboard_url\n end",
"def confirm_totp_secret!( secret, code )\n\n # if it fails…\n return false unless confirm_totp_secret( secret, code )\n\n # update some pointers\n self.second_factor_enabled = true\n save\n\n end",
"def test_ID_25863_comment_on_review()\n login_as_user1\n read_all_updates\n share_review(\"outside-in\")\n logout_common\n login_as_user2\n leave_comment_on_share_review_group(\"outside-in\")\n logout_common\n login_as_user1\n verify_updates\n end",
"def wizard_new\n \n @subtype=params[:sub_type]\n @package = \"\"\n @image = \"\"\n if @subtype == \"1\"\n @package = \"Basic Snack Pack\"\n @image = \"/../assets/new-design/img1-mem.jpg\"\n elsif @subtype == \"2\"\n @package = \"Double Snack Pack\"\n @image = \"/../assets/new-design/img1-mem.jpg\"\n else\n @package = \"Family Snack Pack\"\n @image = \"/../assets/new-design/img1-mem.jpg\"\n end\n @subscription = Subscription.find_by_id @subtype\n unless @subscription.blank?\n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n \nelse\n redirect_to root_path\nend\n \n end"
] |
[
"0.64715683",
"0.6243314",
"0.6169844",
"0.6080056",
"0.60709566",
"0.6019965",
"0.5974508",
"0.59318626",
"0.5923659",
"0.5895076",
"0.58888006",
"0.58883613",
"0.58746284",
"0.58703685",
"0.5864117",
"0.58496326",
"0.5842658",
"0.58064723",
"0.5797942",
"0.57765114",
"0.57736874",
"0.57614636",
"0.57611454",
"0.5746515",
"0.5745988",
"0.5744119",
"0.5704818",
"0.5693384",
"0.56929106",
"0.5655099",
"0.5652518",
"0.5644059",
"0.56425494",
"0.5640926",
"0.5638293",
"0.56339127",
"0.56338596",
"0.56318265",
"0.56237555",
"0.5610319",
"0.5604146",
"0.55887353",
"0.55860233",
"0.5579094",
"0.55741125",
"0.5572778",
"0.55596715",
"0.55522966",
"0.55482686",
"0.55460376",
"0.5529822",
"0.5527767",
"0.5516871",
"0.5509178",
"0.5495085",
"0.5484177",
"0.54802984",
"0.5474477",
"0.5466078",
"0.5466026",
"0.5455741",
"0.5450993",
"0.5447459",
"0.5441952",
"0.5433964",
"0.5421518",
"0.54178596",
"0.5400037",
"0.53989995",
"0.5395514",
"0.5395355",
"0.5393893",
"0.5393893",
"0.53837955",
"0.537973",
"0.53769046",
"0.5374791",
"0.5373998",
"0.5368709",
"0.53649235",
"0.53648084",
"0.5363224",
"0.5353434",
"0.53448194",
"0.5335798",
"0.5332773",
"0.53271466",
"0.5313791",
"0.531178",
"0.5309667",
"0.53052837",
"0.5298413",
"0.52923834",
"0.5283632",
"0.5283077",
"0.52828705",
"0.527864",
"0.5278377",
"0.5278301",
"0.5272944"
] |
0.5986124
|
6
|
STEPS: 1. login on turtle using facebook account 2. search for listing 3. upload image to listing 4. check image 5. hide image
|
def test_fb_sign_up_and_upload_monkey_image
# Step 1
@user.email = @fb_user['email']
login_fb_user!(@fb_user, @user)
# Step 2
assign_http(Config["panda"]["host"])
opts = { 'vrid' => @user.vrid }
get_consumer_search_resp('ramen', 'glendale, ca', opts)
assert_response(@response, :success)
listing = @parsed_response['SearchResult']['BusinessListings'].first
int_xxid = listing['Int_Xxid']
# Step 3
assign_http(Config["monkey"]["host"])
headers = { 'Content-Type' => 'image/jpg' }
params = {
'api_key' => Config["monkey"]["api_key"],
'oauth_token' => @user.oauth_token,
'metadata' => {
'user_type' => 'xx'
}
}
put_file "/b_image", params, generate_random_image, headers
assert_response(@response, :success)
sha1 = @parsed_response['id']
params = {
'ext_type' => 'int_xxid',
'ext_id' => int_xxid,
'oauth_token' => @user.oauth_token,
'api_key' => Config["monkey"]["api_key"],
'metadata' => {
'user_type' => 'xx'
}
}
post "/b_image/#{sha1}", params
assert_response(@response, :success)
# Step 4
assert_image_in_consumer_business(sha1, listing)
assert_image_in_profile(sha1, @user)
# Step 5
assign_http(Config["monkey"]["host"])
params = {
'ext_type' => 'int_xxid',
'ext_id' => int_xxid,
'oauth_token' => @user.oauth_token,
'api_key' => Config["monkey"]["api_key"],
'reason' => 6
}
post "/b_image/#{sha1}/int_xxid/#{int_xxid}/report", params
assert_response(@response, :success)
params = { 'api_key' => Config["monkey"]["api_key"] }
get "/business/images/#{int_xxid}", params
assert_response(@response, :success)
refute_empty(@parsed_response[int_xxid],
"Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}")
refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1),
"Expected image removed from list after delete: #{sha1}")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def atest_ID_25836_edit_profile_pic_03\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_close_photo_upload_dialog\n end",
"def uploading_pictures\n end",
"def atest_ID_25836_edit_profile_pic_02\n login_as_user1\n go_to_edit_profile_page\n verify_unable_to_upload_non_image_file \"PDFDocument\"\n end",
"def atest_ID_25836_edit_profile_pic_04\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_cancel_photo_upload_dialog\n end",
"def test_reuse_image_page_access\n obs = observations(:agaricus_campestris_obs)\n params = { id: obs.id }\n assert_equal(\"rolf\", obs.user.login)\n\n logout\n get(:reuse, params: params)\n assert_response(:login, \"No user: \")\n\n login(\"mary\", \"testpassword\")\n get(:reuse, params: params)\n\n # assert_redirected_to(%r{/#{obs.id}$})\n assert_redirected_to(permanent_observation_path(obs.id))\n\n login(\"rolf\", \"testpassword\")\n get(:reuse, params: params)\n\n assert_response(:success)\n # qr = QueryRecord.last.id.alphabetize\n assert_form_action(action: :attach, id: obs.id)\n end",
"def show\n if @current_user.nil? and (!params[:id].to_i.zero? or User.find_by_username(params[:id]).nil?)\n redirect_to '/login' \n else\n if !params[:id].to_i.zero? and !@current_user.nil? and @current_user.image_ids.include? params[:id].to_i\n @image=Image.find params[:id]\n user=@current_user\n else\n user=User.find_by_username params[:id]\n @image=user.images.random\n end\n @image.text=user.quotes.random\n send_data(@image.to_img(request),\n :type => 'image/png',\n :disposition => 'inline')\n end\n end",
"def picture_list\n end",
"def list\n oauth_check_authorization\n \n @friends = facebook_client.friends_with_pictures\n end",
"def choose_image(discovery, filter)\n \n FlickRaw.api_key=ENV[\"FLICKR_KEY\"]\n FlickRaw.shared_secret=ENV[\"FLICKR_SECRET\"]\n\n bath = flickr.places.find :query => \"Bath\"\n latitude = bath[0]['latitude'].to_f\n longitude = bath[0]['longitude'].to_f\n\n args = {}\n args[:place_id] = bath[0]['place_id']\n args[:accuracy] = 11 #city\n args[:per_page] = 500 #this is max size\n #license ids at: https://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html\n args[:license] = \"7,6,5,4,3,2,1\"\n args[:sort] = discovery\n \n images = flickr.photos.search args\n #puts images.inspect\n images.to_a.shuffle.each do |i|\n if !filter.include?( i[\"id\"] )\n filter.insert( i[\"id\"] )\n return i\n end\n end \n raise \"No image!\"\nend",
"def image(type = \"square\")\n \"https://graph.facebook.com/\" + uid + \"/picture?type=\" + type\n end",
"def repost_pixi\n listing = Listing.new(get_attr(true))\n listing = add_photos false, listing\n listing.generate_token\n listing.status, listing.repost_flg = 'active', true\n listing.set_end_date\n listing.save!\n end",
"def edit_real_picture\n end",
"def fb_image_url(type='square')\n \"http://graph.facebook.com/#{fb_user_id}/picture?type=#{type}\" \n end",
"def upload_a_new_picture(file_name)\n @browser.back_to_top\n #puts(File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-oae/\" + file_name)\n pic_file_element.when_visible { @browser.file_field(:id=>\"profilepicture\").set(\"/Users/abrahamheward/Work/Kuali-Sakai-Functional-Test-Automation-Framework/data/sakai-oae/Mercury.gif\") }#File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-oae/\" + file_name) }\n upload\n sleep 5 \n end",
"def index\n redirect_to_pictureable_path\n end",
"def listing_image\n\t\t\n\t\t@listing_image = ListingImage.find(params[:id])\n\t\tif @listing_image\n\t\t\t#print \"\\n\\n\\n 91#{@listing.id}***\\n\\n\\n\"\n\t\t\tsend_data(@listing_image.data,\n\t\t\t\t\t\t:filename => @listing_image.name,\n\t\t\t\t\t\t:type => @listing_image.content_type,\n\t\t\t\t\t\t:disposition => \"inline\")\n\t\t# else\n\t\t\t# print \"\\n\\n\\n 97 ***\\n\\n\\n\"\n\t\t\t# @f = File.new(\"nopix.jpg\")\n\t\t\t# send_data(\"nopix.jpg\".data, \n\t\t\t\t\t# :filename => \"nopix.jpg\", \n\t\t\t\t\t# :type => \"nopix.jpg\".content_type, \n\t\t\t\t\t# :disposition=>\"inline\")\n\t end\n\t end",
"def check_favorite username, password, slideshow_id\n do_request 'check_favorite', username: username, password: password, slideshow_id: slideshow_id\n end",
"def crawl_flickr(group_id='74191472@N00')\n \n key = \"86c115028094a06ed5cd19cfe72e8f8b\" # FLICKR_KEY\n content_type = \"1\" # Photos only\n flickr_url = \"https://api.flickr.com/services/rest/\"\n method = \"flickr.photos.search\"\n jez = User.find(2)\n black = Colour.find_by_name('black')\n english = Language.find_by_name('English')\n new_photos_count = 0\n \n 19.times do |page|\n puts page.to_s\n url = flickr_url + \"?api_key=\" + key + \"&method=\" + method + \"&page=\" + page.to_s + \"&per_page=5&content_type=\" + content_type + \"&extras=date_taken,owner_name,license,geo,description\"\n if group_id\n url += \"&group_id=\" + group_id\n end\n response = open(url)\n doc = REXML::Document.new(response.read)\n doc.elements.each('//rsp/photos/photo') do |photo|\n print \".\"\n $stdout.flush\n @photo = nil\n file_url = \"http://farm\" + photo.attributes[\"farm\"] + \".staticflickr.com/\" + photo.attributes[\"server\"] + \"/\" + photo.attributes[\"id\"] + \"_\" + photo.attributes[\"secret\"] + \"_z.jpg\"\n photo_url = \"http://www.flickr.com/photos/\" + photo.attributes[\"owner\"] + \"/\" + photo.attributes[\"id\"] + \"/\"\n @photo = Photo.find_by_url(photo_url)\n inscription_is_stub = true\n if photo.attributes[\"title\"]!=nil\n subject = photo.attributes[\"title\"].split(\",\")[0].split(\"()\")[0].rstrip.lstrip + \".\"\n inscription = subject\n end\n if photo.elements[\"description\"].text != nil && photo.elements[\"description\"].text.length > 50\n inscription << \" \" + photo.elements[\"description\"].text\n end\n if @photo\n puts \"photo already exists in Open Plaques\"\n else\n # Plaque find by location and name if already exists.....\n# 32.76696, -94.348526\n# 32.766955, -94.348472\n # Plaque.find_or_create_by_???\n @plaque = Plaque.new(:inscription => inscription, :user => jez, :inscription_is_stub => inscription_is_stub, :colour => black, :language => english)\n @plaque.location = Location.new(:name => 'somewhere in Texas')\n # the Flickr woeids appear to be at town level, so can only create an area from them\n woeid = photo.attributes[\"woeid\"]\n if woeid != nil\n area = Area.find_or_create_by_woeid(woeid)\n if area != nil\n @plaque.location.area = area\n else\n puts \"error: provided woeid \" + woeid + \" but got no area back\"\n end\n end\n if @plaque\n @photo = Photo.new\n @photo.plaque = @plaque\n @photo.file_url = file_url\n @photo.url = photo_url\n @photo.taken_at = photo.attributes[\"datetaken\"]\n @photo.photographer_url = photo_url = \"http://www.flickr.com/photos/\" + photo.attributes[\"owner\"] + \"/\"\n @photo.photographer = photo.attributes[\"ownername\"]\n @photo.licence = Licence.find_by_flickr_licence_id(photo.attributes[\"license\"])\n if photo.attributes[\"latitude\"] != \"0\" && photo.attributes[\"longitude\"] != \"0\" && !@plaque.geolocated?\n @plaque.latitude = photo.attributes[\"latitude\"]\n @plaque.longitude = photo.attributes[\"longitude\"]\n end\n if @plaque.save\n puts \"New plaque and photo added\"\n else\n puts \"Error adding plaque \" + @plaque.errors.full_messages.to_s\n end\n if @photo.save\n puts \"New photo found and saved\"\n else\n puts \"Error saving photo\" + @photo.errors.each_full{|msg| puts msg }\n end\n end\n end\n end\n end\n end",
"def test_unverified_user_fb_sign_up_ugc_merge\n # Step 1\n @user.email = @fb_user['email']\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n @user.login_oauth\n assert(@user.oauth_token)\n\n # Step 2\n assign_http(Config[\"panda\"][\"host\"])\n\n opts = { 'vrid' => @user.vrid }\n\n get_consumer_search_resp('ramen', 'glendale, ca', opts)\n\n assert_response(@response, :success)\n\n listing = @parsed_response['SearchResult']['BusinessListings'].first\n int_xxid = listing['Int_Xxid']\n\n # Step 3\n assign_http(Config[\"monkey\"][\"host\"])\n\n headers = { 'Content-Type' => 'image/jpg' }\n\n params = {\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'oauth_token' => @user.oauth_token,\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n put_file \"/b_image\", params, generate_random_image, headers\n\n assert_response(@response, :success)\n sha1 = @parsed_response['id']\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n post \"/b_image/#{sha1}\", params\n\n assert_response(@response, :success)\n\n # Step 4\n refute_image_in_consumer_business(sha1, listing)\n assert_image_in_profile(sha1, @user)\n\n # Step 5\n login_fb_user!(@fb_user, @user)\n\n # Step 6\n assert_image_in_consumer_business(sha1, listing)\n assert_image_in_profile(sha1, @user)\n\n # Step 7\n assign_http(Config[\"monkey\"][\"host\"])\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'reason' => 6\n }\n\n post \"/b_image/#{sha1}/int_xxid/#{int_xxid}/report\", params\n assert_response(@response, :success)\n\n params = { 'api_key' => Config[\"monkey\"][\"api_key\"] }\n\n get \"/business/images/#{int_xxid}\", params\n assert_response(@response, :success)\n refute_empty(@parsed_response[int_xxid],\n \"Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}\")\n refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1),\n \"Expected image removed from list after delete: #{sha1}\")\n end",
"def facebook\n\n end",
"def proc_facebook_login\n \n puts \"proc_facebook_login\"\n \n puts request.env['rack.auth'].inspect\n \n \n # If user is already logged in, grab session variables\n if session[:user_name] && !session[:user_name].empty?\n @real_name = session[:real_name] \n @user_name = session[:user_name]\n @user_image = session[:user_image] \n else\n # If user is not logged in, grab authentication varaibles\n @real_name = request.env['rack.auth']['user_info']['name']\n @user_name = request.env['rack.auth']['user_info']['name']\n #@user_image = request.env['rack.auth']['user_info']['image']\n @user_image = \"\"\n \n session[:user_name] = @user_name\n session[:real_name] = @real_name\n session[:user_image] = @user_image \n end\n \n @exists = false\n @user_id = -1\n \n #puts \"Checking if user already exists in database...\"\n \n # Check if user already exists in database\n User.all.each do |user|\n if user[:twitter] == @user_name\n @exists = true\n @user_id = user.id\n session[:user_id] = @user_id\n break;\n end\n end\n \n # User does not exist in database. Add new user\n if !@exists\n new_user = User.new( :twitter => @user_name, :name => @real_name )\n new_user.save\n \n @user_id = new_user.id\n session[:user_id] = @user_id\n end\n \n # Redirect to the user home page\n redirect_to :action => \"home\"\n end",
"def index\n\n # Check if whoever made request is logged in, this will be useful for the view to know if it\n # should display the add photo option. Logged in users should see\n # this option and non-logged in users should not.\n if logged_in?\n @logged_in = true\n end\n\n if params[:id] and User.exists?(params[:id])\n \t\t@user = User.find(params[:id])\n if params[:photo_search] and Photo.exists?(params[:photo_search])\n photo = Photo.find(params[:photo_search])\n @user.photos.unshift @user.photos.delete_at(@user.photos.index(photo))\n @highlight_first_photo = true\n end\n else\n add_alert(false, :alert_error, \"That user does not exist, or you did not provide a user id.\")\n end\n\n end",
"def test_ID_25836_edit_profile_pic_01\n login_as_user1\n go_to_edit_profile_page\n file_upload \"valid.jpg\"\n verify_valid_profile_pic_uploaded\n end",
"def show\n @listings = Listing.where(id: @profile.id)\n @user_listings = Listing.where(user_id: @profile.user_id)\n # if ListingPhoto.find_by(listing_id: @user_listings.id) == nil\n # # run this code\n # something\n # else\n # @listing_photo = ListingPhoto.find(listing_id: @user_listings.id)\n # end\n\n @reviews = Review.where(user_id: @profile.user.id)\n \n end",
"def index\n @picture = Picture.all\n if logged_in?\n @favorite = current_user.favorites\n end\n end",
"def show_avatar\n\n end",
"def show_avatar\n\n end",
"def show_image\n store_location\n @image = find_or_goto_index(Image, params[:id].to_s)\n return false unless @image\n\n pass_query_params\n\n # Decide which size to display.\n @default_size = @user ? @user.image_size : :medium\n @size = params[:size].blank? ? @default_size : params[:size].to_sym\n\n # Make this size the default image size for this user.\n if @user && (@default_size != @size) && (params[:make_default] == \"1\")\n @user.image_size = @size\n @user.save_without_our_callbacks\n @default_size = @size\n end\n\n # Wait until here to create this search query to save server resources.\n # Otherwise we'd be creating a new search query for images for every single\n # show_observation request. We know we came from an observation-type page\n # because that's the only time the \"obs\" param will be set (with obs id).\n obs = params[:obs]\n if obs.present? && obs.to_s.match(/^\\d+$/) &&\n # The outer search on observation won't be saved for robots, so no sense\n # in bothering with any of this.\n !browser.bot?\n obs_query = find_or_create_query(:Observation)\n obs_query.current = obs\n img_query = create_query(:Image, :inside_observation,\n observation: obs, outer: obs_query)\n query_params_set(img_query)\n end\n\n # Cast user's vote if passed in \"vote\" parameter.\n if @user &&\n (val = params[:vote]) &&\n (val == \"0\" || (val = Image.validate_vote(val)))\n val = nil if val == \"0\"\n cur = @image.users_vote\n if cur != val\n anon = @user.votes_anonymous == :yes\n @image.change_vote(@user, val, anon: anon)\n end\n\n # Advance to next image automatically if \"next\" parameter set.\n if params[:next]\n query = find_or_create_query(Image)\n query.current = @image\n @image = query.current if query.index(@image) && (query = query.next)\n end\n end\n\n # Grab list of votes.\n @votes = @image.image_votes.sort_by do |v|\n (v.anonymous ? :anonymous.l : v.user.unique_text_name).downcase\n rescue StandardError\n \"?\"\n end\n\n # Update view stats on image we're actually showing.\n update_view_stats(@image)\n end",
"def like_picture\n @like = Like.new(:user_id=>@login_user.id,:likable_id=>params[:id],:likable_type=>\"Image\")\n @pic = Image.find(params[:id])\n if @like.save\n respond_to do |format|\n format.js\n end\n else\n render :text=>\"Fail\"\n end\n end",
"def create\n\n @user = User.find(current_user.id)\n\n load_fb_images\n\n # facebook upload\n if params[:user_image] && params[:user_image][:action]\n if params[:user_image][:action]=='import_facebook_profile_pictures'\n logger.debug 'Processing FB Image Load'\n\n @facebook_profile_pictures.each do |fb_pic|\n if params[:user_image][:picture_ids].include?(fb_pic.identifier)\n logger.debug 'Loading picture --- ' + fb_pic.inspect\n photo=@user.user_images.new()\n photo.picture_from_url(fb_pic.source)\n end\n end\n\n @user.save\n\n end\n @new_photo=UserImage.new(:user_id=>@user.id)\n else\n\n # regular upload -- form submission\n @new_photo=@user.user_images.new(params[:user_image])\n\n if @new_photo.is_profile_pic\n @user.user_images.each do |ui|\n (ui.is_profile_pic=false; ui.save) if ui.id && ui.is_profile_pic\n end\n end\n\n if @user.save\n @new_photo=UserImage.new(:user_id=>@user.id)\n end\n\n end\n\n @profile_pic=@user.profile_pic\n @photos=@user.user_images.all(:conditions=>'is_profile_pic is null or is_profile_pic=false')\n\n render :index\n\n end",
"def image_url\n \"http://graph.facebook.com/#{third_party_id}/picture?type=square\"\n end",
"def create\n @listing = Listing.new\n @listing.title=params[:listing][:title]\n @listing.description=params[:listing][:description]\n # TODO, what if the no category has been created yet?\n if params[:listing][:category_id].nil?\n cat = Category.find_by_description('default')\n if cat.nil?\n cat = Category.new\n cat.description = 'default'\n cat.save!\n end\n @listing.category_id = cat.id\n else\n @listing.category_id = params[:listing][:category_id]\n end\n @listing.user_id = current_user.id #need user id\n\n respond_to do |format|\n begin\n if @listing.save\n flash[:notice] = 'Your listing has been added, awaiting group admin approval.'\n # Now log it to the small box in my profile.\n UserPublisher.deliver_profile_update(current_user)\n\n #Now, check for attachment file. If it exists, save it.\n #TODO, need to extract it & make it into a utility method along with PhotosController.rb\n if (!params[:listing][:uploaded_data].nil?)\n photo_info = Hash.new\n photo_info[:uploaded_data] = params[:listing][:uploaded_data]\n photo_info[:listing_id] = @listing.id.to_s\n if (!params[:photo][:title].nil?)\n photo_info[:title] = params[:photo][:title]\n end\n @photo = Photo.new(photo_info)\n if @photo.save\n data = File.open(@photo.public_filename).read\n file_parameter = Net::HTTP::MultipartPostFile.new(@photo.filename, @photo.content_type, data)\n fb_image = facebook_session.user.upload_photo(file_parameter)\n\n #fb_image has 3 url, .src -> medium, .src_big -> original, .src_small -> thumbnail\n #using hash to update the large and small images on facebook.\n fb_image_links = {'large_fb_image' => fb_image.src_big, 'small_fb_image' => fb_image.src_small}\n @photo.update_attributes(fb_image_links)\n end\n end\n\n # Back to main listing page\n format.html { redirect_to(FB_APP_HOME_URL + listings_path) }\n format.fbml { redirect_to(FB_APP_HOME_URL + listings_path) }\n format.xml { render :xml => @listing, :status => :created, :location => @listing }\n\n #with new2, which does not allow image upload on new listing creation.\n #format.html { redirect_to(listings_path) }\n #format.fbml { redirect_to(listings_path) }\n #format.xml { render :xml => @listing, :status => :created, :location => @listing }\n else\n flash[:notice] = 'Cannot create your listing!'\n format.html { redirect_to FB_APP_HOME_URL + listings_path, :action => \"new\" }\n format.fbml { redirect_to FB_APP_HOME_URL + listings_path, :action => \"new\" }\n format.xml { render :xml => @listing.errors, :status => :unprocessable_entity }\n end\n rescue Exception => e\n flash_text = \"An error occurred in creating the listing: #{e.to_s}\"\n logger.info \"*****#{flash_text}***\"\n @listing.destroy\n flash[:notice] = flash_text\n format.html { redirect_to FB_APP_HOME_URL + listings_path, :action => \"new\" }\n format.fbml { redirect_to FB_APP_HOME_URL + listings_path, :action => \"new\" }\n format.xml { render :xml => @listing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def step_1\n @user = @current_user\n @image = Image.new\n \n\n if request.get?\n if session[:omniauth]\n @current_user.desc = session[:omniauth][\"info\"][\"description\"]\n if session[:omniauth][\"provider\"] == \"weibo\"\n @image.remote_avatar_url = session[:omniauth][\"info\"][\"image\"]\n elsif session[:omniauth][\"provider\"] == \"qq_connect\"\n @image.remote_avatar_url = session[:omniauth][\"info\"][\"figureurl_1\"]\n end\n session[:omniauth] = nil\n end\n @jumpto_url = session[:jumpto]\n session[:jumpto] = nil\n return redirect_to @jumpto_url if @jumpto_url\n render(:template => \"users/step_1\", :layout => \"register\")\n else\n if @user.update_attributes(params[:user])\n redirect_to user_url(@user)\n else\n return\n end\n #redirect_to step_2_user_url(@user)\n end\n end",
"def new\n \n user = FbGraph::User.new('me', :access_token => User.first.token)\n \n user = user.fetch(:fields => \"picture,cover, photo\")\n \n @profile_picture = user.picture unless user.picture.nil?\n\n @cover_picture = user.raw_attributes[:cover][:source] unless user.raw_attributes[:cover].nil?\n \n #To fetch all friends photos\n @friend_photo= (user.friends).map(&:picture) \n \n @photo=[]\n @album=[]\n \n #~ #TO fetch user tagged photos\n #~ usr=user.photos\n #~ usr.each do |up|\n #~ photo = up.raw_attributes['images'].last\n #~ @photo << photo['source']\n #~ end\n \n #~ #TO fetch user all album photos\n #~ user.albums.each do |ua|\n #~ album=FbGraph::Album.new(ua.raw_attributes[:id])\n #~ album.photos(:access_token => User.first.token, :limit => 100).each do |ap|\n #~ photo = ap.raw_attributes['images'].last\n #~ @album << photo['source']\n #~ end\n #~ end\n #mosaic = Mosaicc.new\n Mosaicc.delay.image_perform\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @album }\n end\n end",
"def post_image_on_timeline( _image_id = '')\n unless( _image_id.blank?)\n _image = self.images.find( _image_id)\n _my_fb = self.facebook.fetch\n _my_fb.photo!( :source => File.new( _image.photo.path), :message => _image.description)\n true\n else\n false\n end\n end",
"def facebook\n end",
"def update_photo_identities\n return unless token\n return unless provider_name == \"flickr\"\n return unless ( fi = user.flickr_identity )\n\n fi.token = token\n secret = auth_info.try( :[], \"credentials\" ).try( :[], \"secret\" )\n fi.secret = secret unless secret.blank?\n fi.save\n true\n end",
"def like\n login_to_facebook\n bob.like\nend",
"def import_picture\n if request.post?\n render :text=>\"Nothing to do\"\n else\n @pic= Image.find(params[:id])\n @photo_url = \"http://\"+request.host_with_port + @pic.photo(:original)\n @album = Album.find(:all,:conditions=>[\"user_id=?\",@login_user.id])\n render :partial=>\"albums/import_picture\"\n end\n end",
"def login_using_image(browser_handle, user_prop, user_prop_value, username, pass_prop, pass_prop_value, password, img_prop, img_prop_value)\n browser_handle.text_field(user_prop.intern,user_prop_value).set(username)\n browser_handle.text_field(pass_prop.intern,pass_prop_value).set(password)\n browser_handle.image(/#{img_prop}/.intern, /#{img_prop_value}/).click\nend",
"def show()\n @authentication = Authentication.find(params[:id])\n\n if @authentication.provider == \"facebook\"\n me = FbGraph::User.me(@authentication.token).fetch\n current_user.fname = me.name.split.first\n current_user.lname = me.name.split.last\n current_user.email = me.email\n current_user.gender = me.gender\n birthday = me.birthday\n current_user.birthday = Chronic.parse(birthday) if birthday\n\n location = me.location\n current_user.location = location if location and location.is_a? String\n current_user.location = location.try(:[], :name) if location and location.is_a? Hash\n pictureurl = me.picture+'?type=large'\n begin\n tempfile = Tempfile.new(['', '.jpg'])\n open(tempfile.path, 'wb') do |file|\n file << open(URI.parse(pictureurl)).read\n end\n current_user.avatar = tempfile\n rescue\n end\n end\n\n current_user.save\n redirect_to edit_user_path\n end",
"def getgenres(artist = \"\")\n @check = false\n @artist = RSpotify::Artist.search(artist).first\n unless @artist.nil? || @artist.genres.empty?\n session[:artist] = @artist.name\n session[:id] = @artist.id\n @check = true\n getimage\n end\nend",
"def upload_picture\n \n # Pass through the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Check that the current user is the specified user, or an\n # administrator\n unless @user == current_user or admin_logged_in?\n flash[:error] = 'You cannot upload a profile picture for another user.'\n redirect_to :controller => 'sessions', :action => 'new'\n else\n render :layout => 'dialog'\n end\n end",
"def choose_existing_callback\n if @params['status'] == 'ok'\n WebView.execute_js('showImage(\"'+Rho::RhoApplication::get_blob_path(@params['image_uri'])+'\");')\n end\n end",
"def search\n\n if params[:search].blank?\n flash.now[:notice]= \"Please start to search.\"\n else\n search = params[:search]\n get_flickr_images(search)\n @images = @flickr_images.paginate(page: params[:page], per_page: 50)\n flash.now[:annouce] = \"Click a thumbnail image to view the larger size image.\"\n end\n render :home\n\n end",
"def Managerfb\n session[:check] = 1\n redirect_to '/auth/facebook'\n end",
"def picture\n\t\tid = params.has_key?(:id)?params[:id]:nil\n\t\t\n\t\tredirect_to '/assets/default_user.jpg' and return if id.nil?\n\t\t\n\t\tuser = User.find_by_id(id)\n\t\t\n\t\t#User picture\n\t\tif (!user.nil? && !user.fb_id.nil?)\n\t\t\tredirect_to 'https://graph.facebook.com/'+user.fb_id.to_s+'/picture?type=square' and return\n\t\telse\n\t\t\tredirect_to '/assets/default_user.jpg' and return\n\t\tend\n\t\n\t\trender :text=>id\n\tend",
"def search_for_images(token, phrase)\r\n request = {\r\n :RequestHeader => { :Token => token},\r\n :SearchForImages2RequestBody => {\r\n :Query => { :SearchPhrase => phrase},\r\n :ResultOptions => {\r\n :ItemCount => 25,\r\n :ItemStartNumber => 1\r\n },\r\n :Filter => { :ImageFamilies => [\"creative\"], :Orientations => ['Horizontal']}\r\n }\r\n }\r\n response = post_json(request, \"http://connect.gettyimages.com/v1/search/SearchForImages\")\r\n\r\n #status = response[\"ResponseHeader\"][\"Status\"]\r\n #images = response[\"SearchForImagesResult\"][\"Images\"]\r\n end",
"def index\n @raw_images = RawImage.all\n #@user = current_user\n #@authorized = true\n end",
"def hide\n user = current_user\n\n if user\n checked_images = params[:checked_images]\n max = params[:max]\n\n\t if checked_images\n\t\t ActiveRecord::Base.transaction do\n\t\t checked_images.each do |indexer|\n\t\t databased_image = Image.where(indexer: indexer).first\n\t\t if databased_image\n\t\t HiddenImage.where(image_id: databased_image.id, user_id: user.id).first_or_create\n\t\t end\n\t\t end\n\t\t end\n\t end\n redirect_to images_path max: max\n else\n # Nope - not logged in!\n redirect_to root_path\n end\n end",
"def show_image # :nologin: :prefetch:\n store_location\n if @image = find_or_goto_index(Image, params[:id].to_s, :include => [\n :copyright_changes,\n :image_votes,\n :license,\n {:observations => [:comments, :name]},\n :projects,\n :user,\n ])\n @is_reviewer = is_reviewer\n pass_query_params\n\n # Decide which size to display.\n @default_size = @user ? @user.image_size : :medium\n @size = params[:size].blank? ? @default_size : params[:size].to_sym\n\n # Make this size the default image size for this user.\n if @user and (@default_size != @size) and\n (params[:make_default] == '1')\n @user.image_size = @size\n @user.save_without_our_callbacks\n @default_size = @size\n end\n\n # Wait until here to create this search query to save server resources.\n # Otherwise we'd be creating a new search query for images for every single\n # show_observation request. We know we came from an observation-type page\n # because that's the only time the 'obs' param will be set (with obs id).\n obs = params[:obs]\n if !obs.blank? &&\n # The outer search on observation won't be saved for robots, so no sense\n # in bothering with any of this.\n !is_robot?\n obs_query = find_or_create_query(:Observation)\n obs_query.current = obs\n img_query = create_query(:Image, :inside_observation,\n :observation => obs, :outer => obs_query)\n set_query_params(img_query)\n end\n\n # Cast user's vote if passed in 'vote' parameter.\n if @user and\n (val = params[:vote]) and\n (val == '0' or (val = Image.validate_vote(val)))\n val = nil if val == '0'\n cur = @image.users_vote\n if cur != val\n anon = @user.votes_anonymous == :yes\n @image.change_vote(@user, val, anon)\n Transaction.put_images(:id => @image, :set_vote => val, :set_anonymous => anon)\n end\n\n # Advance to next image automatically if 'next' parameter set.\n if params[:next]\n query = find_or_create_query(Image)\n query.current = @image\n if query.index(@image) and\n (query = query.next)\n @image = query.current\n end\n end\n end\n\n # Grab list of votes.\n @votes = @image.image_votes(:include => :user).sort_by do |v|\n (v.anonymous ? :anonymous.l : v.user.unique_text_name).downcase\n end\n\n # Update view stats on image we're actually showing.\n update_view_stats(@image)\n end\n end",
"def image_url \n if fb_id\n \"http://graph.facebook.com/#{fb_id}/picture?height=200\"\n end\n end",
"def show\n require 'net/http'\n require 'net/https'\n require 'uri'\n require 'json'\n\n begin\n group_id = @post.groupId\n parameters = {\"v\" => \"5.95\", \"access_token\" => @post.token}\n\n url = \"https://api.vk.com/method/photos.getWallUploadServer?group_id=\" + group_id.to_s\n serverInfo = make_request(url, parameters)\n\n uri = URI.parse serverInfo[\"upload_url\"]\n connection = Net::HTTP.new uri.host, uri.port\n connection.use_ssl = true\n request = Net::HTTP::Post.new uri\n form_data = [\n ['photo', File.open(@post.image.current_path)]\n ]\n request.set_form form_data, 'multipart/form-data'\n @response = connection.request request\n photoInfo = JSON.parse(@response.body)\n\n url = \"https://api.vk.com/method/photos.saveWallPhoto?group_id=\" + group_id.to_s + \"&server=\" + photoInfo[\"server\"].to_s + \"&photo=\" + photoInfo[\"photo\"].to_s + \"&hash=\" + photoInfo[\"hash\"].to_s\n uploadedPhotoInfo = make_request(url, parameters)\n\n if @post.descriprion != \"\"\n url = \"https://api.vk.com/method/wall.post?owner_id=-\" + group_id.to_s + \"&from_group=1&message=\" + @post.descriprion.to_s + \"&attachments=photo\" + uploadedPhotoInfo[0][\"owner_id\"].to_s + \"_\" + uploadedPhotoInfo[0][\"id\"].to_s\n else\n url = \"https://api.vk.com/method/wall.post?owner_id=-\" + group_id.to_s + \"&from_group=1&attachments=photo\" + uploadedPhotoInfo[0][\"owner_id\"].to_s + \"_\" + uploadedPhotoInfo[0][\"id\"].to_s\n end\n post = make_request(url, parameters)\n\n @info = \"https://vk.com/clash_attack?w=wall-\" + group_id.to_s + \"_\" + post[\"post_id\"].to_s\n rescue Exception => e\n @info = \"We have some errors, sorry!\"\n print e\n end\n\n end",
"def add_photos_from_site\n if(params[:photo_url])\n @url = params[:photo_url]\n @album = Album.find(:all,:conditions=>[\"user_id=?\",@login_user.id])\n render :action=>\"add_photos_from_site\", :layout=>false\n end\n \n end",
"def add_images\n @specification = Specification.where(florist_id: session[\"found_florist_id\"]).where(id: params[\"specification_id\"]).first \n render(:images) and return\n end",
"def show\n begin\n @listing = Listing.find(params[:id])\n rescue Exception => e\n if e.class == ActiveRecord::RecordNotFound\n logger.info(\"No such listing by id: #{params[:id]}\")\n end\n @listing = nil\n return false\n end\n\n if @listing.user_id == current_user.id \n @is_owner = true\n @private_listing = false\n elsif verify_admin_status == true\n @is_admin = true\n @private_listing = false\n else\n @is_owner = false\n if @listing.private?\n @private_listing = true\n end\n end\n\n respond_to do |format|\n remove_fb_sig_friends_from_params\n format.html # show.html.erb\n format.fbml # show.fbml.erb\n format.xml { render :xml => @listing }\n end\n end",
"def test_reuse_image_for_user\n requires_login(:reuse_image, mode: \"profile\")\n assert_template(\"reuse_image\", partial: \"_image_reuse\")\n assert_form_action(action: \"reuse_image\", mode: \"profile\")\n end",
"def test_ID_25836_edit_profile_pic\n login_as_user1\n go_to_edit_profile_page\n verify_valid_profile_pic_uploaded \"valid\"\n verify_unable_to_upload_non_image_file \"PDFDocument\"\n verify_user_able_to_close_photo_upload_dialog\n verify_user_able_to_cancel_photo_upload_dialog\n end",
"def show\n if user_signed_in?\n send_image\n else\n evaluate_visibility\n end\n end",
"def like_picture\n @like = Like.new(:user_id=>@login_user.id,:likable_id=>params[:id],:likable_type=>\"Picture\")\n @pic = Picture.find(params[:id])\n if @like.save\n respond_to do |format|\n format.js\n end\n else\n render :text=>\"Fail\"\n end\n end",
"def image_url\n \"https://graph.facebook.com/#{id}/picture\"\n end",
"def show\n\n # Get random gif from Giphy (http://giphy.com)\n response = HTTParty.get('http://api.giphy.com/v1/gifs/search?' +\n 'q=' + @boolio.val.to_s +\n '&api_key=dc6zaTOxFJmzC' + # provided for public beta testing via (https://github.com/Giphy/GiphyAPI#public-beta-key)\n '&limit=1' + # only want 1\n '&offset=' + rand(30).to_s + # pull from the top 10 most relevant images\n '&rating=pg' + # afraid if this is any higher\n '&fmt=json' # seems to return JSON anyway, but just in case\n )\n\n if response.code == 200\n\n # conver to JSON\n json = JSON.parse response.body, object_class: OpenStruct\n\n # set image from returned results\n @image = json.data[0].images if json.data.count > 0\n end\n\n end",
"def upload_user_bikes\n end",
"def test04_group_photo_all\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_1.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$span_3_frames.click\n\t\t$upload_frames_save.click\t\n\tend",
"def get_picture(type='square')\n if self.social_sessions.first.social_network.username == 'facebook'\n return \"http://graph.facebook.com/#{self.id_on_social}/picture?type=#{type}\"\n end\n end",
"def advanced_search # :nologin: :norobots:\n begin\n query = find_query(:Image)\n show_selected_images(query)\n rescue => err\n flash_error(err.to_s) if !err.blank?\n redirect_to(:controller => 'observer', :action => 'advanced_search')\n end\n end",
"def photoRequest( id )\n image_tag \"http://graph.facebook.com/#{id}/picture?type=square\", \n :class => \"friendWallPhoto round\", \n 'data-facebook-uid' => \"#{id}\"\n end",
"def update\n\n @user = User.find(current_user.id)\n\n @photo=@user.user_images.find(params[:id])\n\n # hook into these actions\n if params[:user_image][:action]=='make_profile_picture'\n # turn off all the other ones.\n @user.user_images.each do |ui|\n (ui.is_profile_pic=false; ui.save) if ui.id && ui.is_profile_pic\n end\n\n @photo.is_profile_pic=true\n @photo.save\n end\n\n @profile_pic=@user.profile_pic\n @photos=@user.user_images.all(:conditions=>'is_profile_pic is null or is_profile_pic=false')\n @new_photo=UserImage.new(:user_id=>@user.id)\n\n load_fb_images\n\n render :index\n\n end",
"def test04_fb_login_existing_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($facebook_home)\n\t\tfb_login\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T4: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def view\n if belongs_to_user?(@good)\n @good_images = [@good.main_image] + Image.ad_images_of_good(@good)\n @good_images.flatten!\n else\n redirect_to root_path, alert: 'Это не ваша сохраненная вещь'\n end\n end",
"def home\n \tif !params[:user_id].blank?\n\n \t\t@user_id = flickr.people.getInfo(:user_id => params[:user_id])\n \n \t \tget_pics_by_id\n\n \tend\t\n end",
"def postPhotoClick( sender )\n \n\t\t# Just use the icon image from the application itself. A real app would have a more \n\t\t# useful way to get an image.\n\t\timg = UIImage.imageNamed( \"Icon-72@2x.png\" )\n\n\t\t# Build the request for uploading the photo\n\t\tphotoUploadRequest = FBRequest.requestForUploadPhoto( img )\n\n\t\t# Then fire it off.\n\t\tphotoUploadRequest.startWithCompletionHandler(\n\t\t\tlambda { |connection, result, error|\n\t\t \tself.showAlert( \"Photo Post\", result: result, error: error )\n\t\t \t@buttonPostPhoto.enabled = false\n\t\t }\n\t\t)\n\t \n\t @buttonPostPhoto.enabled = false\n\tend",
"def show\n\n @listing = Listing.find(params[:id])\n # if @photos\n # @photos = @listing.listingphotos\n # else\n # message = \"photos is nil\"\n # raise RuntimeError.new message\n # end\n end",
"def show #Should show the item depending on the requested item, not on the current user!\n begin\n @listing = Listing.find(:first, :conditions => [\"id = ? and removed = ? and creation = ?\", params[:id], \"0\", \"completed\"])\n if !self.current_user.blank?\n @favorite = Favorite.find(:first, :conditions => [\"user_id = ? and listing_id = ?\", self.current_user.id, @listing.id])\n @hearted = Hearted.find(:first, :conditions => [\"user_id = ? and listing_id = ?\", self.current_user.id, @listing.id])\n end \n @listings = Listing.find(:all, :conditions => [\"seller_id = ? and id != ? and removed = ? and creation = ?\", @listing.seller_id, @listing.id, \"0\", \"completed\"], :limit => 10)\n logger.info @listings.inspect\n #Select items for the carrousel\n @pictures = []\n @listings.each do |l| \n @pic = l.pic1.url(:small)\n logger.info \"run\"\n logger.info @pic.inspect\n @pictures << @pic\n end \n logger.info @pictures.inspect\n @shop = Shop.find(:first, :conditions => [\"seller_id = ?\", @listing.seller_id]) \n @l1_link = listing_overview_path\n @l1_name = \"Items\"\n @l2_link = listing_path\n if self.current_user\n if self.current_user.is_seller? and self.current_user.seller.id == @listing.seller_id\n @l2_name = \"Item \" + @listing.id.to_s \n else\n @l2_name = \"Item \" + @listing.id.to_s\n end\n end\n @listing.v += 1\n @listing.save\n rescue\n flash[:notice_bad] = t(\"controllers.listings.s5\")\n redirect_to site_path\n else\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @listing }\n end\n end\nend",
"def search\n images = Google.instance.image_search(params[:text])\n if images.empty?\n render status: :not_found, body: t('controllers.giffy.search.no_results')\n return\n end\n\n num = [1.0/rand, images.size - 1].min\n image = images[num.to_i]\n\n Slack.instance.echo command\n Slack.instance.webhook_message command.channel_id, image, icon_url: view_context.image_url('giffy.png')\n\n head :ok\n end",
"def test_reuse_image_for_user_post1\n image = images(:commercial_inquiry_image)\n params = { mode: \"profile\", img_id: image.id.to_s }\n requires_login(:reuse_image, params)\n assert_redirected_to(user_path(rolf.id))\n assert_equal(rolf.id, session[:user_id])\n assert_equal(image.id, rolf.reload.image_id)\n end",
"def show\n # Block execution if there is no current user\n if(current_user.blank?)\n return render json:{\n errors: \"true\",\n message: \"User not connected\"\n }, status: 401\n end\n show= User.find_by(id:current_user.id)\n #atta = photo de profil\n atta = show.featured_image.attached?\n if atta \n avatar = rails_blob_path(show.featured_image)\n render json:{\n user:show,avatar:avatar,photo:atta\n }\n else \n render json:{\n user:show,photo:atta\n }\n end\n end",
"def pic_preview_golink page_url, img_url, link_id, img_id, input_id\n queryparams = { picurl: img_url, golinkid: link_id }\n queryparams[:pageurl] = page_url if page_url\n button_to_submit page_url ? \"Pick Picture...\" : \"Get Picture from Web...\",\n pic_picker_new_path(queryparams),\n \"default\",\n \"small\",\n id: link_id,\n preload: true,\n :mode => :modal,\n class: \"pic_picker_golink\",\n data: { inputid: input_id, imageid: img_id }\n end",
"def show_image\n if @wine.picture.attached?\n image_tag(@wine.picture.service_url, alt: \"your_image\", height: \"250\", style: \"border: 1px solid #220F24\")\n end\n end",
"def camera_callback\n if @params['status'] == 'ok'\n puts \"ENTER CALLBACK WITH THIS PRODUCT ID!!!!!!!!!!!! #{$placehold}\"\n #puts \"THIS IS THE LOCATION OF THE IMAGE!!!!!! #{@params}\"\n \n #This is taking the picture and encoding it in base64 to display on device and upload if needed.\n #The io portion is taking the opened inmage and converting it to a String.\n #temp = Base64.encode64(open(@params['image_uri']) {|io| io.read})\n #puts \"!~~~!~!~!~!~!~!~!~!~!~!~!~! #{temp}\"\n\n #$placehold.update_attributes({\"image\" => \"data:image/jpeg;base64,\" + temp.to_s })\n $placehold.update_attributes({\"image\" => @params['image_uri']})\n #puts \"CHECK UPDATE!!!!!!! #{$placehold}\"\n else\n Alert.show_popup(\n :message => @params['status'],\n :title => 'ERROR',\n :buttons => ['ok'],\n :callback => url_for(:action => :index_callback)\n )\n end\n WebView.navigate(url_for :action => :picture, :id => $placehold.object)\n end",
"def images\n @picturesandmeta = Pictureandmeta.all\n @kind = Kind.find(params[:kind_id])\n Rails.logger.info(\"Kind: #{@kind.inspect}\")\n end",
"def fb_get_results(client, page_div)\n results = []\n\n images = page_div.query_selector_all(\n 'a[href^=\"https://www.facebook.com/\"][href*=\"search\"] ' +\n 'img[src*=\"profile\"]')\n images.each do |image|\n image_src = image.attributes['src']\n link = image\n until element_matches(client, link, 'a')\n link = element_parent client, link\n end\n link_href = link.attributes['href']\n if match = (/^https:\\/\\/www\\.facebook\\.com\\/([^\\/\\?]+)\\?/i).\n match(link_href)\n profile_name = match[1]\n else\n # Discard profiles without usernames.\n # TODO(pwnall): consider accepting profiles with IDs, if they ever come\n # up\n p link_href\n next\n end\n results << {\n name: profile_name,\n pic: image_src,\n url: link_href,\n }\n end\n results\nend",
"def test03_fb_login_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\t\t\n\t\tfb_allow\n\t\t$browser.goto($facebook_home)\n\t\t$facebook_dropdown.click\n\t\t$facebook_logout.click\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T3: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def show\n @image = Image.find(params[:id])\n if @image.account.user_id != session[:user_id] then\n render :text => \"Attempt to view an unauthorized record.\", :status => \"401\"\n return false\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @image }\n format.xml { render :xml => @image }\n end\n end",
"def next_image # :nologin: :norobots:\n redirect_to_next_object(:next, Image, params[:id].to_s)\n end",
"def top_image(url)\n og_image = check_og_image(url)\n apple_image = check_apple_image(url)\n mechanize_search = mechanize_search(url)\n if og_image\n return og_image\n elsif apple_image\n return apple_image\n elsif mechanize_search\n mechanize_search \n # In case all else fails ...\n else\n \"../image-dne.jpg\"\n end\n end",
"def set_listing\n @listing = Listing.find(params[:id])\n @pictures = @listing.pictures\n end",
"def index\n @q = Listing.ransack(params[:q])\n @listings = @q.result.with_attached_picture.paginate(:page => params[:page], :per_page=>8)\n end",
"def fav_img_tag(projectile_id, user_id)\n if isFavorited? projectile_id, user_id\n icon = 'icon_small_star.png'\n #link_to :favorite\n #link_to image_tag(icon), :favorite, :method => :post, :projectile_id => projectile_id, :user_id => user_id \n else\n icon = 'icon_small_star_inactive.png'\n #link_to_remote {:url => favorites_path, :method => :post, :remote => :true, :id => 'img_' + projectile_id.to_s }, { :projectile_id => projectile_id, :user_id => user_id, :body => image_tag(icon)} \n end\n image_submit_tag( icon, :id => 'img_' + projectile_id.to_s )\n\nend",
"def test_reuse_image_for_user_post2\n image = images(:commercial_inquiry_image)\n params = { mode: \"profile\", img_id: image.id.to_s }\n post_requires_login(:reuse_image, params)\n assert_redirected_to(user_path(rolf.id))\n assert_equal(rolf.id, session[:user_id])\n assert_equal(image.id, rolf.reload.image_id)\n end",
"def photos_for_workout(workout)\n query = \"SELECT pid FROM photo WHERE aid IN ( SELECT aid FROM album WHERE name='#{workout}' and owner=331358835234 ) ORDER BY created\"\n p MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n end",
"def addpic\n @user = User.find_by_id(session[:remember_token]) \n @photo = params[:user][:pic]\n if @user.pic != @photo\n @user.update_attributes(:pic => @photo)\n render 'home/loggedin'\n end\n end",
"def upload_to_flickr!\n # download image to tmp/\n photo_path = download_from_instagram\n @log.debug(\"Path is #{photo_path}\")\n # upload to flickr\n flickr.access_token = @params['flickr_access_token']\n flickr.access_secret = @params['flickr_access_secret']\n response = flickr.upload_photo photo_path, :title => @payload['title'], :description => @payload['caption'] \n @log.debug(\"Flickr Response = #{response}\")\n # push it into the Redii and delete local version.\n add_to_storage\n File.delete(photo_path)\n end",
"def browse\n #@listings = Listing.find(:all, :order => \"type\")\n @user = current_user\n @listings = Listing.find(:all, \n :conditions => [\"user_id != ? and status = 'new'\",@user.id ],\n :order => :type, \n :page => {:size => 4, :current => params[:page]})\n @header_type = \"Browse All Listings\"\n \n \n end",
"def upload\n begin\n solve(@viewable_list,@browse_list)\n render :result\n rescue Exception => e\n raise_error INCORRECT_DATA\n end\n end",
"def run()\n\t\t\t# Get first page of albums\n\t\t\tfb_albums = @graph.get_connections(\"mojeSarajevo\",\"albums\")\n\n\t\t\t# IDs\n\t\t\tnum_of_albums = 0\n\t\t\tnum_of_photos = 0\n\t\t\tnum_of_comments = 0\n\t\t\tnum_of_users = 0\n\n\t\t\twhile fb_albums.size > 0\n\t\t\t\tputs \"\\tRetrieving #{fb_albums.size} albums...\"\n\t\t\t\t\n\t\t\t\t# Get albums\n\t\t\t\tfb_albums.each do |fb_album|\n\t\t\t\t\tnum_of_albums += 1\n\t\t\t\t\t\n\t\t\t\t\t# Get album photos\n\t\t\t\t\tfb_photos = @graph.get_connections(fb_album['id'],\"photos\")\n\n\t\t\t\t\twhile fb_photos.size > 0\n\t\t\t\t\t\tputs \"\\t\\tRetrieving #{fb_photos.size} photos...\"\n\t\t\t\t\t\tfb_photos.each do |fb_photo|\n\t\t\t\t\t\t\tnum_of_photos += 1\n\t\t\t\t\t\t\t# 0. create new user if one doesn't exist yet \n\t\t\t\t\t\t\t# 1. create issue for each photo\n\t\t\t\t\t\t\t# 2. create attachment with photo URL\n\t\t\t\t\t\t\t# 3. create issue updates from comments\n\n\t\t\t\t\t\t\t# 0. User\n\t\t\t\t\t\t\tfb_user_id = fb_photo['from']['id']\n\t\t\t\t\t\t\tuser = User.find_by_fb_id(fb_user_id)\n\t\t\t\t\t\t\tif (user.nil?)\n\t\t\t\t\t\t\t\tuser = create_user(fb_user_id)\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tfb_photo_id = fb_photo['id']\n\t\t\t\t\t\t\tfb_item = FbItem.find_by_fb_id(fb_photo_id)\n\n\t\t\t\t\t\t\t# first time\n\t\t\t\t\t\t\tif (fb_item.nil?)\n\t\t\t\t\t\t\t\tfb_item = FbItem.new\n\t\t\t\t\t\t\t\tissue = Issue.new\n\t\t\t\t\t\t\t\tattachment = Attachment.new\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tissue = Issue.find(fb_item.ssg_id)\n\t\t\t\t\t\t\t\tattachment = issue.attachments.first\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Was this photo updated after the import?\n\t\t\t\t\t\t\tif (fb_item.fb_updated_at.nil? || fb_item.fb_updated_at < fb_photo['updated_time'])\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t# 1. Issue\n\t\t\t\t\t\t\t\tissue.name = \"Moj grad, moja sigurnost, moja odgovornost - Issue \\##{num_of_photos}\"\n\t\t\t\t\t\t\t\tissue.description = \"This issue is created from \\\"Moj grad, moja sigurnost, moja odgovornost\\\" - Facebook ID=#{fb_photo['id']}\"\n\t\t\t\t\t\t\t\tif (!fb_photo['place'].nil?)\n\t\t\t\t\t\t\t\t\tissue.latitude = fb_photo['place']['location']['latitude']\n\t\t\t\t\t\t\t\t\tissue.longitude = fb_photo['place']['location']['longitude']\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tuser.issues << issue\n\n\t\t\t\t\t\t\t\t# 2. Attachment\n\t\t\t\t\t\t\t\tattachment.file_type = Attachment::JPG\n\t\t\t\t\t\t\t\tattachment.name = !fb_photo['name'].nil? ? fb_photo['name'] : \"Attachment\"\n\t\t\t\t\t\t\t\tattachment.URL = fb_photo['source']\n\t\t\t\t\t\t\t\tattachment.width = fb_photo['width']\n\t\t\t\t\t\t\t\tattachment.height = fb_photo['height']\n\t\t\t\t\t\t\t\tattachment.user = user\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tissue.attachments << attachment\n\n\t\t\t\t\t\t\t\t# 1.1 FBItem for photo\n\t\t\t\t\t\t\t\tfb_item.fb_object_type = FbItem::PHOTO\n\t\t\t\t\t\t\t\tfb_item.name = fb_photo['name']\n\t\t\t\t\t\t\t\tfb_item.fb_id = fb_photo_id\n\t\t\t\t\t\t\t\tfb_item.ssg_id = issue.id\n\t\t\t\t\t\t\t\tfb_item.fb_created_at = fb_photo['created_time']\n\t\t\t\t\t\t\t\tfb_item.fb_updated_at = fb_photo['updated_time']\n\n\t\t\t\t\t\t\t\t# save to DB\n\t\t\t\t\t\t\t\tuser.save\n\t\t\t\t\t\t\t\tissue.save\n\t\t\t\t\t\t\t\tattachment.save\n\t\t\t\t\t\t\t\tfb_item.save\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tputs \"\\t\\tPhoto: ID=#{fb_photo_id}\"\t\n\t\t\t\t\t\t\tend\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t# retrieve photo comments\n\t\t\t\t\t\t\tfb_comments = @graph.get_connections(fb_photo_id,\"comments\")\n\n\t\t\t\t\t\t\twhile fb_comments.size > 0\n\t\t\t\t\t\t\t\tputs \"\\t\\t\\tRetriving #{fb_comments.size} comments..\"\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tfb_comments.each do |fb_comment|\n\t\t\t\t\t\t\t\t\tfb_user_id = fb_comment['from']['id']\n\t\t\t\t\t\t\t\t\tfb_comment_id = fb_comment['id']\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t# Get or create user\n\t\t\t\t\t\t\t\t\tuser = User.find_by_fb_id(fb_user_id)\n\t\t\t\t\t\t\t\t\tif (user.nil?)\n\t\t\t\t\t\t\t\t\t\tuser = create_user(fb_user_id)\n\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\t# Update existing\n\t\t\t\t\t\t\t\t\tfb_item = FbItem.find_by_fb_id(fb_comment_id)\n\n\t\t\t\t\t\t\t\t\t# Comments cannot be updated so we're skipping already imported\n\t\t\t\t\t\t\t\t\tif (fb_item.nil?)\n\t\t\t\t\t\t\t\t\t\tfb_item = FbItem.new\n\t\t\t\t\t\t\t\t\t\tissue_update = IssueUpdate.new\n\n\t\t\t\t\t\t\t\t\t\t# Create issue update from comment\n\t\t\t\t\t\t\t\t\t\tissue_update.description = fb_comment['message']\n\t\t\t\t\t\t\t\t\t\tissue_update.user = user\n\t\t\t\t\t\t\t\t\t\tissue_update.save\n\n\t\t\t\t\t\t\t\t\t\tissue.issue_updates << issue_update\n\t\t\t\t\t\t\t\t\t\tissue.save\n\n\t\t\t\t\t\t\t\t\t\t# 1.1 FBItem for comment\n\t\t\t\t\t\t\t\t\t\tfb_item.fb_object_type = FbItem::COMMENT\n\t\t\t\t\t\t\t\t\t\tfb_item.name = fb_comment['name']\n\t\t\t\t\t\t\t\t\t\tfb_item.fb_id = fb_comment_id\n\t\t\t\t\t\t\t\t\t\tfb_item.ssg_id = issue_update.id\n\t\t\t\t\t\t\t\t\t\tfb_item.fb_created_at = fb_comment['created_time']\n\t\t\t\t\t\t\t\t\t\tfb_item.save\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t# Get next comments\n\t\t\t\t\t\t\t\tfb_comments = fb_comments.next_page\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\tend\t\t\t\t\t\t\n\t\t\t\t\t\t# Get next set of photos\n\t\t\t\t\t\tfb_photos = fb_photos.next_page\n\t\t\t\t\tend\n\n\t\t\t\t\t# Save album to fb_items\n\t\t\t\t\tfb_album_id = fb_album['id']\n\t\t\t\t\tfb_item = FbItem.find_by_fb_id(fb_album_id)\n\n\t\t\t\t\tif (fb_item.nil?)\n\t\t\t\t\t\tfb_item = FbItem.new\n\t\t\t\t\tend\n\n\t\t\t\t\tif (fb_item.fb_updated_at.nil? || fb_item.fb_updated_at < fb_album['updated_time'])\n\t\t\t\t\t\tfb_item.fb_id = fb_album_id\n\t\t\t\t\t\tfb_item.ssg_id = -1\n\t\t\t\t\t\tfb_item.fb_object_type = FbItem::ALBUM\n\t\t\t\t\t\tfb_item.name = fb_album['name']\n\t\t\t\t\t\tfb_item.fb_created_at = fb_album['created_time']\n\t\t\t\t\t\tfb_item.fb_updated_at = fb_album['updated_time']\n\t\t\t\t\t\tfb_item.save\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Get next set of albums\n\t\t\t\tfb_albums = fb_albums.next_page\n\t\t\tend\n\n\t\t\tputs \"Exported: Albums=#{num_of_albums}, Photos=#{num_of_photos}, Comments=#{num_of_comments}, Users=#{num_of_users}\"\n\t\tend",
"def show_verification_photo var\n\t\tmutate.verification_photo_preview_shown true\n\t\tGalleryStore.toggle_open true\n\tend",
"def photo_discussions\n @album = Album.find(:all,:conditions=>[\"user_id=?\",@login_user.id])\n from = Time.now-30.days\n to = Time.now\n page = 1\n order_by_rating = false\n @pictures = @login_user.all_visible_pictures(from, to, page,order_by_rating,0,0)\n #@pictures = Picture.paginate(:page => 1, :per_page => 5)\n end",
"def show\n \tif !logged_in?\n \t\tredirect_to :controller => :sessions, :action => :new, :return_to => request.request_uri\n \telse\n\t \tlogin = params[:login]\n\t \t@user = User.find_by_login(login)\n\t \t@user_stream = @user.profile_stream_short\n\t \t@user.images.highest_ranked.each do |i|\n\t \t\t@image = i.photo.url(:profile)\n\t\t\tend\t\t\t \t\n\t \t@cats = @user.cats.paginate :page => params[:page], :order => \"created_at desc\", :per_page => 30\n\t \t@user.profile ||= Profile.new\n\t \t@profile = @user.profile\n \tend\n end",
"def choose_existing\n Camera::choose_picture(url_for(:action => :choose_existing_callback))\n end"
] |
[
"0.5973723",
"0.5827267",
"0.58178514",
"0.58116597",
"0.5743193",
"0.57244116",
"0.5716951",
"0.5665135",
"0.56402797",
"0.5595061",
"0.558402",
"0.5533642",
"0.55262864",
"0.55206966",
"0.551238",
"0.5486385",
"0.5484302",
"0.5481954",
"0.5470436",
"0.5465468",
"0.5462275",
"0.5458814",
"0.54581964",
"0.5455006",
"0.5449194",
"0.5438976",
"0.5438976",
"0.5416634",
"0.5404537",
"0.539601",
"0.53824323",
"0.5382261",
"0.5370668",
"0.53698325",
"0.5369005",
"0.53686833",
"0.5342266",
"0.53272223",
"0.5326762",
"0.53239334",
"0.5321883",
"0.53218037",
"0.5306934",
"0.5302726",
"0.530021",
"0.5299621",
"0.52970266",
"0.5292549",
"0.52885103",
"0.52843326",
"0.52831656",
"0.5278088",
"0.5277491",
"0.5277396",
"0.5261975",
"0.52598214",
"0.5257186",
"0.5252572",
"0.52508825",
"0.5249744",
"0.5247496",
"0.5244687",
"0.52429974",
"0.52422637",
"0.5240021",
"0.5237168",
"0.52349937",
"0.5231437",
"0.52242243",
"0.5216861",
"0.52103585",
"0.52090025",
"0.52016336",
"0.51971036",
"0.51951814",
"0.51889426",
"0.5185297",
"0.51830983",
"0.51825714",
"0.518219",
"0.5175386",
"0.5174675",
"0.5174661",
"0.51741004",
"0.51672566",
"0.51625717",
"0.5156625",
"0.5148875",
"0.51439315",
"0.5143408",
"0.5142079",
"0.5137271",
"0.51342154",
"0.5129276",
"0.51291084",
"0.51243246",
"0.5123239",
"0.5119969",
"0.51168466",
"0.51132894"
] |
0.5998476
|
0
|
STEPS: 1. sign up and login on turtle with same email as fb 2. search for listing 3. upload image to listing 4. check image in profile, but not in mip 5. login via fb of same email 6. check image in mip and profile 7. hide image
|
def test_unverified_user_fb_sign_up_ugc_merge
# Step 1
@user.email = @fb_user['email']
turtle_response = @user.register
assert_response(turtle_response, :success)
assert(@user.id)
@user.login_oauth
assert(@user.oauth_token)
# Step 2
assign_http(Config["panda"]["host"])
opts = { 'vrid' => @user.vrid }
get_consumer_search_resp('ramen', 'glendale, ca', opts)
assert_response(@response, :success)
listing = @parsed_response['SearchResult']['BusinessListings'].first
int_xxid = listing['Int_Xxid']
# Step 3
assign_http(Config["monkey"]["host"])
headers = { 'Content-Type' => 'image/jpg' }
params = {
'api_key' => Config["monkey"]["api_key"],
'oauth_token' => @user.oauth_token,
'metadata' => {
'user_type' => 'xx'
}
}
put_file "/b_image", params, generate_random_image, headers
assert_response(@response, :success)
sha1 = @parsed_response['id']
params = {
'ext_type' => 'int_xxid',
'ext_id' => int_xxid,
'oauth_token' => @user.oauth_token,
'api_key' => Config["monkey"]["api_key"],
'metadata' => {
'user_type' => 'xx'
}
}
post "/b_image/#{sha1}", params
assert_response(@response, :success)
# Step 4
refute_image_in_consumer_business(sha1, listing)
assert_image_in_profile(sha1, @user)
# Step 5
login_fb_user!(@fb_user, @user)
# Step 6
assert_image_in_consumer_business(sha1, listing)
assert_image_in_profile(sha1, @user)
# Step 7
assign_http(Config["monkey"]["host"])
params = {
'ext_type' => 'int_xxid',
'ext_id' => int_xxid,
'oauth_token' => @user.oauth_token,
'api_key' => Config["monkey"]["api_key"],
'reason' => 6
}
post "/b_image/#{sha1}/int_xxid/#{int_xxid}/report", params
assert_response(@response, :success)
params = { 'api_key' => Config["monkey"]["api_key"] }
get "/business/images/#{int_xxid}", params
assert_response(@response, :success)
refute_empty(@parsed_response[int_xxid],
"Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}")
refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1),
"Expected image removed from list after delete: #{sha1}")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def atest_ID_25836_edit_profile_pic_02\n login_as_user1\n go_to_edit_profile_page\n verify_unable_to_upload_non_image_file \"PDFDocument\"\n end",
"def atest_ID_25836_edit_profile_pic_03\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_close_photo_upload_dialog\n end",
"def atest_ID_25836_edit_profile_pic_04\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_cancel_photo_upload_dialog\n end",
"def step_1\n @user = @current_user\n @image = Image.new\n \n\n if request.get?\n if session[:omniauth]\n @current_user.desc = session[:omniauth][\"info\"][\"description\"]\n if session[:omniauth][\"provider\"] == \"weibo\"\n @image.remote_avatar_url = session[:omniauth][\"info\"][\"image\"]\n elsif session[:omniauth][\"provider\"] == \"qq_connect\"\n @image.remote_avatar_url = session[:omniauth][\"info\"][\"figureurl_1\"]\n end\n session[:omniauth] = nil\n end\n @jumpto_url = session[:jumpto]\n session[:jumpto] = nil\n return redirect_to @jumpto_url if @jumpto_url\n render(:template => \"users/step_1\", :layout => \"register\")\n else\n if @user.update_attributes(params[:user])\n redirect_to user_url(@user)\n else\n return\n end\n #redirect_to step_2_user_url(@user)\n end\n end",
"def test_fb_sign_up_and_upload_monkey_image\n # Step 1\n @user.email = @fb_user['email']\n login_fb_user!(@fb_user, @user)\n\n # Step 2\n assign_http(Config[\"panda\"][\"host\"])\n\n opts = { 'vrid' => @user.vrid }\n\n get_consumer_search_resp('ramen', 'glendale, ca', opts)\n assert_response(@response, :success)\n\n listing = @parsed_response['SearchResult']['BusinessListings'].first\n int_xxid = listing['Int_Xxid']\n\n # Step 3\n assign_http(Config[\"monkey\"][\"host\"])\n\n headers = { 'Content-Type' => 'image/jpg' }\n\n params = {\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'oauth_token' => @user.oauth_token,\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n put_file \"/b_image\", params, generate_random_image, headers\n assert_response(@response, :success)\n\n sha1 = @parsed_response['id']\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'metadata' => {\n 'user_type' => 'xx'\n }\n }\n\n post \"/b_image/#{sha1}\", params\n assert_response(@response, :success)\n\n # Step 4\n assert_image_in_consumer_business(sha1, listing)\n assert_image_in_profile(sha1, @user)\n\n # Step 5\n assign_http(Config[\"monkey\"][\"host\"])\n\n params = {\n 'ext_type' => 'int_xxid',\n 'ext_id' => int_xxid,\n 'oauth_token' => @user.oauth_token,\n 'api_key' => Config[\"monkey\"][\"api_key\"],\n 'reason' => 6\n }\n\n post \"/b_image/#{sha1}/int_xxid/#{int_xxid}/report\", params\n assert_response(@response, :success)\n\n params = { 'api_key' => Config[\"monkey\"][\"api_key\"] }\n\n get \"/business/images/#{int_xxid}\", params\n assert_response(@response, :success)\n refute_empty(@parsed_response[int_xxid],\n \"Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}\")\n refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1),\n \"Expected image removed from list after delete: #{sha1}\")\n end",
"def test_reuse_image_page_access\n obs = observations(:agaricus_campestris_obs)\n params = { id: obs.id }\n assert_equal(\"rolf\", obs.user.login)\n\n logout\n get(:reuse, params: params)\n assert_response(:login, \"No user: \")\n\n login(\"mary\", \"testpassword\")\n get(:reuse, params: params)\n\n # assert_redirected_to(%r{/#{obs.id}$})\n assert_redirected_to(permanent_observation_path(obs.id))\n\n login(\"rolf\", \"testpassword\")\n get(:reuse, params: params)\n\n assert_response(:success)\n # qr = QueryRecord.last.id.alphabetize\n assert_form_action(action: :attach, id: obs.id)\n end",
"def test_reuse_image_for_user\n requires_login(:reuse_image, mode: \"profile\")\n assert_template(\"reuse_image\", partial: \"_image_reuse\")\n assert_form_action(action: \"reuse_image\", mode: \"profile\")\n end",
"def test_ID_25836_edit_profile_pic\n login_as_user1\n go_to_edit_profile_page\n verify_valid_profile_pic_uploaded \"valid\"\n verify_unable_to_upload_non_image_file \"PDFDocument\"\n verify_user_able_to_close_photo_upload_dialog\n verify_user_able_to_cancel_photo_upload_dialog\n end",
"def test_ID_25836_edit_profile_pic_01\n login_as_user1\n go_to_edit_profile_page\n file_upload \"valid.jpg\"\n verify_valid_profile_pic_uploaded\n end",
"def test_reuse_image_for_user_post1\n image = images(:commercial_inquiry_image)\n params = { mode: \"profile\", img_id: image.id.to_s }\n requires_login(:reuse_image, params)\n assert_redirected_to(user_path(rolf.id))\n assert_equal(rolf.id, session[:user_id])\n assert_equal(image.id, rolf.reload.image_id)\n end",
"def test_reuse_image_for_user_post2\n image = images(:commercial_inquiry_image)\n params = { mode: \"profile\", img_id: image.id.to_s }\n post_requires_login(:reuse_image, params)\n assert_redirected_to(user_path(rolf.id))\n assert_equal(rolf.id, session[:user_id])\n assert_equal(image.id, rolf.reload.image_id)\n end",
"def raster_profile_picture(user)\n if user.authentications.where(:provider == \"Facebook\").any?\n fb_picture(user)\n elsif user.authentications.where(:provider == \"Twitter\").any?\n twitter_picture(user, type: \"normal\") \n else\n image_tag user.avatar.url(:raster), class: \"img-circle small_profile_picture\"\n end\n end",
"def update\n\n @user = User.find(current_user.id)\n\n @photo=@user.user_images.find(params[:id])\n\n # hook into these actions\n if params[:user_image][:action]=='make_profile_picture'\n # turn off all the other ones.\n @user.user_images.each do |ui|\n (ui.is_profile_pic=false; ui.save) if ui.id && ui.is_profile_pic\n end\n\n @photo.is_profile_pic=true\n @photo.save\n end\n\n @profile_pic=@user.profile_pic\n @photos=@user.user_images.all(:conditions=>'is_profile_pic is null or is_profile_pic=false')\n @new_photo=UserImage.new(:user_id=>@user.id)\n\n load_fb_images\n\n render :index\n\n end",
"def create\n\n @user = User.find(current_user.id)\n\n load_fb_images\n\n # facebook upload\n if params[:user_image] && params[:user_image][:action]\n if params[:user_image][:action]=='import_facebook_profile_pictures'\n logger.debug 'Processing FB Image Load'\n\n @facebook_profile_pictures.each do |fb_pic|\n if params[:user_image][:picture_ids].include?(fb_pic.identifier)\n logger.debug 'Loading picture --- ' + fb_pic.inspect\n photo=@user.user_images.new()\n photo.picture_from_url(fb_pic.source)\n end\n end\n\n @user.save\n\n end\n @new_photo=UserImage.new(:user_id=>@user.id)\n else\n\n # regular upload -- form submission\n @new_photo=@user.user_images.new(params[:user_image])\n\n if @new_photo.is_profile_pic\n @user.user_images.each do |ui|\n (ui.is_profile_pic=false; ui.save) if ui.id && ui.is_profile_pic\n end\n end\n\n if @user.save\n @new_photo=UserImage.new(:user_id=>@user.id)\n end\n\n end\n\n @profile_pic=@user.profile_pic\n @photos=@user.user_images.all(:conditions=>'is_profile_pic is null or is_profile_pic=false')\n\n render :index\n\n end",
"def show\n if @current_user.nil? and (!params[:id].to_i.zero? or User.find_by_username(params[:id]).nil?)\n redirect_to '/login' \n else\n if !params[:id].to_i.zero? and !@current_user.nil? and @current_user.image_ids.include? params[:id].to_i\n @image=Image.find params[:id]\n user=@current_user\n else\n user=User.find_by_username params[:id]\n @image=user.images.random\n end\n @image.text=user.quotes.random\n send_data(@image.to_img(request),\n :type => 'image/png',\n :disposition => 'inline')\n end\n end",
"def addpic\n @user = User.find_by_id(session[:remember_token]) \n @photo = params[:user][:pic]\n if @user.pic != @photo\n @user.update_attributes(:pic => @photo)\n render 'home/loggedin'\n end\n end",
"def country_flag\n unless session[:user].blank?\n if !session[:user].country.image.blank?\n return image_tag(url_for_file_column(session[:user].country, \"image\",\"main\"))\n else \n \n end\n end\nend",
"def upload_picture\n \n # Pass through the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Check that the current user is the specified user, or an\n # administrator\n unless @user == current_user or admin_logged_in?\n flash[:error] = 'You cannot upload a profile picture for another user.'\n redirect_to :controller => 'sessions', :action => 'new'\n else\n render :layout => 'dialog'\n end\n end",
"def index\n\n # Check if whoever made request is logged in, this will be useful for the view to know if it\n # should display the add photo option. Logged in users should see\n # this option and non-logged in users should not.\n if logged_in?\n @logged_in = true\n end\n\n if params[:id] and User.exists?(params[:id])\n \t\t@user = User.find(params[:id])\n if params[:photo_search] and Photo.exists?(params[:photo_search])\n photo = Photo.find(params[:photo_search])\n @user.photos.unshift @user.photos.delete_at(@user.photos.index(photo))\n @highlight_first_photo = true\n end\n else\n add_alert(false, :alert_error, \"That user does not exist, or you did not provide a user id.\")\n end\n\n end",
"def verify_user\n user = User.where(email: login_params[:email]).first\n if user && user.validate_image(login_params[:image])\n UserNotifierMailer.send_login_email(user, request.user_agent, true).deliver\n render json: {message: 'OK'}, status: :ok\n else\n UserNotifierMailer.send_login_email(user, request.user_agent, false).deliver\n render json: {message: 'No Autorizado'}, status: :unauthorized\n end\n end",
"def nm_maint\n unless current_authuser.id == 60581\n flash[:notice] = \"We're verry sorry, but we are still having some problems with our web image uploader. You can still use our mobile app for iphone and android. Thank you for using DailyMugshot!\"\n redirect_to :root\n end\n end",
"def test_00070_add_feild_as_show_feild\n first_name = @c.users[user_for_test].name.split(' ')[0]\n # set first name feild as not show\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => false }\n # admin can't see first name feild\n @profile_page.goto_profile\n url = @browser.url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can't see first name feild\n @login_page.about_login(\"regular_user2\", \"logged\")\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)\n\n # set first name feild as show\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => true, 2 => false }\n # admin can't see first name feild]\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can't see first name feild\n @login_page.about_login(\"regular_user2\", \"logged\")\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (!@profile_page.profile_page_author_name_betaon.text.include? first_name)\n\n # set first name feild as public\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => true, 2 => true }\n # admin can see first name feild\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can see first name feild\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n ensure\n # set first name feild as public\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {2 => true }\n end",
"def profile_image(id)\n unless id.blank?\n profile = Profile.find_by_user_id(id)\n if !profile.profile_image.blank?\n return url_for_file_column(profile, \"profile_image\",\"submain\")\n else \n return \"/images/home/noprofile_photo.gif\"\n end\nend\nend",
"def picture_show\n path =current_user.user_picture.path.present? ? current_user.user_picture.path.gsub(\"/home/altius/Uma/project/BC4_api/public/\",\"http://192.168.1.238:4020/\") : nil #{}\"http://192.168.1.238:4020/uploads/notfount_image.jpg\"\n user = User.select(:name, :email, :user_uid, :mobile_no, :id).find(current_user.id)\n cg_id = UserAssociation.where(patient_id: current_user.id).pluck(:caregiver_id) != [] ? UserAssociation.where(patient_id: current_user.id).pluck(:caregiver_id) : nil\n caregiver = User.where(id: cg_id)\n pat_id = UserAssociation.where(caregiver_id: current_user.id).pluck(:patient_id) != [] ? UserAssociation.where(caregiver_id: current_user.id).pluck(:patient_id) : nil\n patient = User.where(id: pat_id)\n render json: {profile_pic: path, user_info: user, caregiver: caregiver, patient: patient }, status: :ok\n end",
"def login_using_image(browser_handle, user_prop, user_prop_value, username, pass_prop, pass_prop_value, password, img_prop, img_prop_value)\n browser_handle.text_field(user_prop.intern,user_prop_value).set(username)\n browser_handle.text_field(pass_prop.intern,pass_prop_value).set(password)\n browser_handle.image(/#{img_prop}/.intern, /#{img_prop_value}/).click\nend",
"def update_photo_identities\n return unless token\n return unless provider_name == \"flickr\"\n return unless ( fi = user.flickr_identity )\n\n fi.token = token\n secret = auth_info.try( :[], \"credentials\" ).try( :[], \"secret\" )\n fi.secret = secret unless secret.blank?\n fi.save\n true\n end",
"def proc_facebook_login\n \n puts \"proc_facebook_login\"\n \n puts request.env['rack.auth'].inspect\n \n \n # If user is already logged in, grab session variables\n if session[:user_name] && !session[:user_name].empty?\n @real_name = session[:real_name] \n @user_name = session[:user_name]\n @user_image = session[:user_image] \n else\n # If user is not logged in, grab authentication varaibles\n @real_name = request.env['rack.auth']['user_info']['name']\n @user_name = request.env['rack.auth']['user_info']['name']\n #@user_image = request.env['rack.auth']['user_info']['image']\n @user_image = \"\"\n \n session[:user_name] = @user_name\n session[:real_name] = @real_name\n session[:user_image] = @user_image \n end\n \n @exists = false\n @user_id = -1\n \n #puts \"Checking if user already exists in database...\"\n \n # Check if user already exists in database\n User.all.each do |user|\n if user[:twitter] == @user_name\n @exists = true\n @user_id = user.id\n session[:user_id] = @user_id\n break;\n end\n end\n \n # User does not exist in database. Add new user\n if !@exists\n new_user = User.new( :twitter => @user_name, :name => @real_name )\n new_user.save\n \n @user_id = new_user.id\n session[:user_id] = @user_id\n end\n \n # Redirect to the user home page\n redirect_to :action => \"home\"\n end",
"def sign_up( data )\n\n # assert url starts with 'https://listings.expressupdateusa.com/Account/Register'\n puts 'Signing up with email: ' + data[ 'personal_email' ]\n\n @browser.goto 'https://listings.expressupdateusa.com/Account/Register'\n\n @browser.text_field(:id => 'Email').set data['email']\n @browser.text_field(:id => 'Password').set data['password']\n @browser.text_field(:id => 'ConfirmPassword').set data['password']\n @browser.text_field(:id => 'Phone').set data['phone']\n @browser.text_field(:id => 'BusinessName').set data['business_name']\n @browser.text_field(:id => 'FirstName').set data['firstname']\n @browser.text_field(:id => 'LastName').set data['lastname']\n @browser.select_list(:id => 'State').select data['state']\n @browser.checkbox(:id => 'DoesAcceptTerms').set\n\n\nenter_captcha\n\n@browser.button(:class => 'RegisterNowButton').click\n\n # If no return URl then 'Thank You for Registering with Express Update. An activation email sent!'\n\nself.save_account(\"Expressupdateusa\", { :email => data['personal_email'], :password => data['password']})\n\n\nif @chained\n self.start(\"Expressupdateusa/Verify\")\nend\n\n\ntrue \nend",
"def show\n if user_signed_in?\n send_image\n else\n evaluate_visibility\n end\n end",
"def show_image # :nologin: :prefetch:\n store_location\n if @image = find_or_goto_index(Image, params[:id].to_s, :include => [\n :copyright_changes,\n :image_votes,\n :license,\n {:observations => [:comments, :name]},\n :projects,\n :user,\n ])\n @is_reviewer = is_reviewer\n pass_query_params\n\n # Decide which size to display.\n @default_size = @user ? @user.image_size : :medium\n @size = params[:size].blank? ? @default_size : params[:size].to_sym\n\n # Make this size the default image size for this user.\n if @user and (@default_size != @size) and\n (params[:make_default] == '1')\n @user.image_size = @size\n @user.save_without_our_callbacks\n @default_size = @size\n end\n\n # Wait until here to create this search query to save server resources.\n # Otherwise we'd be creating a new search query for images for every single\n # show_observation request. We know we came from an observation-type page\n # because that's the only time the 'obs' param will be set (with obs id).\n obs = params[:obs]\n if !obs.blank? &&\n # The outer search on observation won't be saved for robots, so no sense\n # in bothering with any of this.\n !is_robot?\n obs_query = find_or_create_query(:Observation)\n obs_query.current = obs\n img_query = create_query(:Image, :inside_observation,\n :observation => obs, :outer => obs_query)\n set_query_params(img_query)\n end\n\n # Cast user's vote if passed in 'vote' parameter.\n if @user and\n (val = params[:vote]) and\n (val == '0' or (val = Image.validate_vote(val)))\n val = nil if val == '0'\n cur = @image.users_vote\n if cur != val\n anon = @user.votes_anonymous == :yes\n @image.change_vote(@user, val, anon)\n Transaction.put_images(:id => @image, :set_vote => val, :set_anonymous => anon)\n end\n\n # Advance to next image automatically if 'next' parameter set.\n if params[:next]\n query = find_or_create_query(Image)\n query.current = @image\n if query.index(@image) and\n (query = query.next)\n @image = query.current\n end\n end\n end\n\n # Grab list of votes.\n @votes = @image.image_votes(:include => :user).sort_by do |v|\n (v.anonymous ? :anonymous.l : v.user.unique_text_name).downcase\n end\n\n # Update view stats on image we're actually showing.\n update_view_stats(@image)\n end\n end",
"def show_verification_photo var\n\t\tmutate.verification_photo_preview_shown true\n\t\tGalleryStore.toggle_open true\n\tend",
"def avatar\n \t\t# get the email from URL-parameters or what have you and make lowercase\n\t\temail_address = self.email.downcase\n\t\t \n\t\t# create the md5 hash\n\t\thash = Digest::MD5.hexdigest(email_address)\n\t\t \n\t\t# compile URL which can be used in <img src=\"RIGHT_HERE\"...\n\t\timage_src = \"http://www.gravatar.com/avatar/#{hash}\"\n \tend",
"def show_image\n store_location\n @image = find_or_goto_index(Image, params[:id].to_s)\n return false unless @image\n\n pass_query_params\n\n # Decide which size to display.\n @default_size = @user ? @user.image_size : :medium\n @size = params[:size].blank? ? @default_size : params[:size].to_sym\n\n # Make this size the default image size for this user.\n if @user && (@default_size != @size) && (params[:make_default] == \"1\")\n @user.image_size = @size\n @user.save_without_our_callbacks\n @default_size = @size\n end\n\n # Wait until here to create this search query to save server resources.\n # Otherwise we'd be creating a new search query for images for every single\n # show_observation request. We know we came from an observation-type page\n # because that's the only time the \"obs\" param will be set (with obs id).\n obs = params[:obs]\n if obs.present? && obs.to_s.match(/^\\d+$/) &&\n # The outer search on observation won't be saved for robots, so no sense\n # in bothering with any of this.\n !browser.bot?\n obs_query = find_or_create_query(:Observation)\n obs_query.current = obs\n img_query = create_query(:Image, :inside_observation,\n observation: obs, outer: obs_query)\n query_params_set(img_query)\n end\n\n # Cast user's vote if passed in \"vote\" parameter.\n if @user &&\n (val = params[:vote]) &&\n (val == \"0\" || (val = Image.validate_vote(val)))\n val = nil if val == \"0\"\n cur = @image.users_vote\n if cur != val\n anon = @user.votes_anonymous == :yes\n @image.change_vote(@user, val, anon: anon)\n end\n\n # Advance to next image automatically if \"next\" parameter set.\n if params[:next]\n query = find_or_create_query(Image)\n query.current = @image\n @image = query.current if query.index(@image) && (query = query.next)\n end\n end\n\n # Grab list of votes.\n @votes = @image.image_votes.sort_by do |v|\n (v.anonymous ? :anonymous.l : v.user.unique_text_name).downcase\n rescue StandardError\n \"?\"\n end\n\n # Update view stats on image we're actually showing.\n update_view_stats(@image)\n end",
"def index\n query_current_user = \"created_by = \\\"#{current_user.email}\\\"\"\n query_public = \"created_by != \\\"#{current_user.email}\\\" AND visibility = 'public'\"\n\n # Use the built-in with_attached_images scope to avoid N+1 queries\n @photos_current_user = Photo.where(query_current_user).with_attached_images\n @photos_public = Photo.where(query_public).with_attached_images\n end",
"def im_for_user(username)\n user = users.find do |u|\n u['name'] == username\n end\n ims.find do |im|\n im['user'] == user['id']\n end\n end",
"def show\n @listings = Listing.where(id: @profile.id)\n @user_listings = Listing.where(user_id: @profile.user_id)\n # if ListingPhoto.find_by(listing_id: @user_listings.id) == nil\n # # run this code\n # something\n # else\n # @listing_photo = ListingPhoto.find(listing_id: @user_listings.id)\n # end\n\n @reviews = Review.where(user_id: @profile.user.id)\n \n end",
"def test_reuse_user_profile_image_as_itself\n user = users(:rolf)\n assert((img = user.image), \"Test needs User fixture with profile image\")\n params = { mode: \"profile\", img_id: img.id }\n\n login(user.login)\n get(:reuse_image, params: params)\n\n assert_equal(img, user.image)\n assert_flash_text(:runtime_no_changes.l)\n end",
"def public_image(who_asks)\n raise \"public_lastname: #{who_asks} is no User\" unless who_asks.is_a? User\n if (who_asks.shapter_admin or (who_asks.schools & self.schools).any? or self.is_friend_with?(who_asks) or who_asks == self)\n image\n else\n nil\n end\n end",
"def show\n unless current_user.id==@image.user_id\n flash[:notice] = \"You don't have access!\"\n redirect_to root_path\n return\n end\n end",
"def show\n begin\n query = \"created_by = \\\"#{current_user.email}\\\" OR visibility = 'public'\"\n @photo = Photo.where(query).with_attached_images.find(params[:id])\n @user_current = current_user.email\n\n #/photos/1: when 1 doesn't belong to the current user and is private\n rescue StandardError => e\n redirect_to photos_path, notice: 'Sorry, you have no permission to view this photo.'\n end\n end",
"def upload_a_new_picture(file_name)\n @browser.back_to_top\n #puts(File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-oae/\" + file_name)\n pic_file_element.when_visible { @browser.file_field(:id=>\"profilepicture\").set(\"/Users/abrahamheward/Work/Kuali-Sakai-Functional-Test-Automation-Framework/data/sakai-oae/Mercury.gif\") }#File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-oae/\" + file_name) }\n upload\n sleep 5 \n end",
"def show_avatar\n\n end",
"def show_avatar\n\n end",
"def uploading_pictures\n end",
"def profile_photo\n\tend",
"def profile_image hash = {}\n image_name = hash.delete(:image_name) ||\n @controller.instance_variable_get(:@profile_user).feed.name.titlecase.\n gsub(/[\\/\\\\\\!\\@\\#\\$\\%\\^\\*\\&\\-\\.\\,\\?]+/, ' ').gsub(' ', '').underscore\n hash.update :action => 'profile_image', :id =>\n image_name, :format => (hash[:format] || 'jpeg'), :trailing_slash => false\n home(hash)\n end",
"def update\n \tif not user_signed_in? # if user is not signed in, they should not be allowed to view this page or be redirected\n \t\trespond_to do |format|\n \t\t\tformat.html { redirect_to root_url }\n \t\tend\n \t\treturn\n \tend \t\n \t\n \tuser_profile = Profile.where('id = ?',params[:profile_id]).first\n \tif user_profile.nil? or user_profile.user_id.to_i != current_user.id.to_i # if the current profile id does not exist, then cannot proceed; if not our profile, cannot proceed: not authorized\n \t\trespond_to do |format|\n \t\t\tformat.html { redirect_to root_url }\n \t\tend\n \t\treturn\n \tend\n \t \t\t\n \timage = Image.where('id = ? AND profile_id = ?',params[:id],user_profile.id).first\n \tif not image.nil?\n \t\t# must do the existing profile check here because must know the image to compare with first (in new, didn't have anything to compare with)\n\t \t@existing_profile_image = Image.where('profile_id = ? AND profile_picture = ?',user_profile.id,true).first\n\t \tif params[:image][:profile_picture].to_i == 1 and not @existing_profile_image.nil? and @existing_profile_image.id.to_i != image.id.to_i # already have a specified profile image? if so, unmark it\n\t \t\t@existing_profile_image = Image.update(@existing_profile_image.id, :profile_picture => false)\n\t \tend\n \t\t\n \t\tnew_name = (params[:image][:name].to_s.empty? ? '[untitled]' : params[:image][:name].to_s)\n \t\tcurrent_image = Image.update(image.id, :name => new_name, :profile_picture => params[:image][:profile_picture], :image_description => params[:image][:image_description]) \t\n \t\tredirect_to :action => :index\n \telse # still not a valid image (logged in user trying to modify an image that doesn't exist for them)\n \t\trespond_to do |format|\n \t\t\tformat.html { redirect_to root_url }\n \t\tend\n \t\treturn\n \tend\n end",
"def photos\n @user = User.find(params[:id])\n @type = params[:type]\n unless read_fragment(:part => \"photos_#{@type}_#{@user.id}\")\n if(@type == \"new\" && @user.last_photo_uploaded_at < 5.minutes.ago)\n @photos = @user.recently_submitted_photos.where(\"created_at > ?\", @user.recently_submitted_photos.first.created_at - 1.day).reverse\n elsif(@type == \"updated\")\n @photos = @user.updated_photos.where(\"updated_at > ?\", 1.day.ago).reverse\n elsif(@type == \"popular\")\n @photos = @user.popular_photos.limit(50)\n elsif(@type != \"new\")\n @photos = @user.photos.limit(50)\n end\n end\n\n#if request.user_agent.downcase.include? \"google\"\n# UserMailer.notify_admins(\"User photos for #{@user.display_name} has been requested by a google bot\").deliver\n# end\n\n respond_to do |format|\n format.html { render :layout => false}\n format.xml { render :xml => @user }\n end\n end",
"def edit\n @user = User.find_by_id(params[:id])\n logged_in_user = session[:user_hash][\"username\"]\n if logged_in_user != @user.sunet and not \n User.is_power_user(logged_in_user)\n # permission denied\n flash[:error] = \"Your privileges don't allow you to edit profiles other than your own.\"\n redirect_to \"/users#/users/\"\n end\n @photos = Photo.find_all_by_user_id(params[:id])\n end",
"def edit\n @user = User.find_by_id(params[:id])\n logged_in_user = session[:user_hash][\"username\"]\n if logged_in_user != @user.sunet and not \n User.is_power_user(logged_in_user)\n # permission denied\n flash[:error] = \"Your privileges don't allow you to edit profiles other than your own.\"\n redirect_to \"/users#/users/\"\n end\n @photos = Photo.find_all_by_user_id(params[:id])\n end",
"def receiver_picture\n user = users.select { |user| !user.id.eql?(sent_by) }.first\n user.avatar_url\n end",
"def wizard_new\n \n @subtype=params[:sub_type]\n @package = \"\"\n @image = \"\"\n if @subtype == \"1\"\n @package = \"Basic Snack Pack\"\n @image = \"/../assets/new-design/img1-mem.jpg\"\n elsif @subtype == \"2\"\n @package = \"Double Snack Pack\"\n @image = \"/../assets/new-design/img1-mem.jpg\"\n else\n @package = \"Family Snack Pack\"\n @image = \"/../assets/new-design/img1-mem.jpg\"\n end\n @subscription = Subscription.find_by_id @subtype\n unless @subscription.blank?\n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n \nelse\n redirect_to root_path\nend\n \n end",
"def show()\n @authentication = Authentication.find(params[:id])\n\n if @authentication.provider == \"facebook\"\n me = FbGraph::User.me(@authentication.token).fetch\n current_user.fname = me.name.split.first\n current_user.lname = me.name.split.last\n current_user.email = me.email\n current_user.gender = me.gender\n birthday = me.birthday\n current_user.birthday = Chronic.parse(birthday) if birthday\n\n location = me.location\n current_user.location = location if location and location.is_a? String\n current_user.location = location.try(:[], :name) if location and location.is_a? Hash\n pictureurl = me.picture+'?type=large'\n begin\n tempfile = Tempfile.new(['', '.jpg'])\n open(tempfile.path, 'wb') do |file|\n file << open(URI.parse(pictureurl)).read\n end\n current_user.avatar = tempfile\n rescue\n end\n end\n\n current_user.save\n redirect_to edit_user_path\n end",
"def image_url\n# Somehow the picture field returns false for 'nil?' regardless of wether it's set or not\n# So we'll have to check if the size of the url is 0 to see if it exists\n# There should be a better way to do this, probably?\nif self.picture.size == 0\n\tself.profile_picture.nil? ? 'image-unknown.jpg' : self.profile_picture\nelse \n\tself.picture.ava\nend\nend",
"def repost_pixi\n listing = Listing.new(get_attr(true))\n listing = add_photos false, listing\n listing.generate_token\n listing.status, listing.repost_flg = 'active', true\n listing.set_end_date\n listing.save!\n end",
"def show\n if @user_profile.image.attachment \n @profile_image = @user_profile.image\n else\n @profile_image = \"https://api.adorable.io/avatars/200/#{current_user.username}\" \n end\n end",
"def effective_avatar(ob, user, query)\n\n picture = ob.profile.picture\n\n if picture\n result = rest_reference(picture, query, true)\n result.name = \"avatar\"\n result\n else\n result = LibXML::XML::Node.new('avatar')\n result['resource'] = Conf.base_uri + '/images/avatar.png'\n result\n end\nend",
"def check_favorite username, password, slideshow_id\n do_request 'check_favorite', username: username, password: password, slideshow_id: slideshow_id\n end",
"def test04_group_photo_all\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_1.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$span_3_frames.click\n\t\t$upload_frames_save.click\t\n\tend",
"def photos\n @trip_report = TripReport.find(params[:id])\n \n unless read_fragment(:part => \"photos_#{@trip_report.id}\")\n @photos = @trip_report.photos.includes(:title_places)\n @has_photos = @photos.length != 0\n end\n\n#if request.user_agent.downcase.include? \"google\"\n# UserMailer.notify_admins(\"Trip photos for #{@trip_report.title} has been requested by a google bot\").deliver\n# end\n\n respond_to do |format|\n format.html { render :layout => false}\n format.xml { render :xml => @user }\n end\n end",
"def show\n #get the user with the url\n @user = User.find(params[:id])\n\n #check if user is the one logged in\n if session[:user_id].to_s == params[:id]\n #then show all his pictures\n @photos = @user.photos\n else\n #show only public pictures\n @photos = @user.photos.where(\"is_private = false\")\n end\n\n end",
"def upload(chatroom_url,email,password,shortcut,file_path)\n signin_get = RestClient.get('https://www.hipchat.com/sign_in')\n signin_doc = Nokogiri::HTML(signin_get)\n xsrf_token = signin_doc.css('input[name=\"xsrf_token\"]').first.attributes[\"value\"].value\n\n signin_response = RestClient.post('https://www.hipchat.com/sign_in', \n\t {email: email, password: password,d: nil,stay_signed_in: 1,signin: \"Log+in\",xsrf_token: xsrf_token},\n {cookies: signin_get.cookies}){|response, request, result, &block| response}\n \n if signin_response.code != 302\n return \"Error - could not sign in: please provide valid credentials\"\n end\n\n # GET emoticons page to store an xsrf_token\n get_request = RestClient.get(\"#{chatroom_url}/admin/emoticons\", {cookies: signin_response.cookies})\n html_doc = Nokogiri::HTML(get_request)\n xsrf_token = html_doc.css('input[name=\"xsrf_token\"]').first.attributes[\"value\"].value\n \n\n if get_request.code != 200\n return \"Error - could not reach emoticons page. Make sure you provided the right chatroom_url\"\n end\n\n puts 'finished sigining in'\n\n # POST the progress - expect a 200 code\n progress = RestClient.post(\"#{chatroom_url}/admin/progress\",\n\t\t\t\t\t\t {shortcut: shortcut, xsrf_token: xsrf_token},\n\t\t\t\t\t\t {:cookies => signin_response.cookies}){|response, request, result, &block| response}\n if progress.code != 200\n return \"Error - something broke when posting to progress - check with someone who knows what they are doing\"\n end\n\n puts \" POST Progress: #{progress.code}\"\n \n # POST the emoticon - expect a 302 code\n emoticon = RestClient.post(\"#{chatroom_url}/admin/emoticons\",\n\t\t{'shortcut' => shortcut,\n\t\t'action' => 'add',\n\t\t'xsrf_token' => xsrf_token,\n\t\t'submit_emoticon' => 'Add emoticon',\n\t\t'fileName' => \"#{shortcut}.png\",\n\t\t'Filedata' => File.new(file_path,'rb')},\n\t\t{:cookies => signin_response.cookies}){|resp, req, rslt, &blk| resp}\n puts \"POST Emoticon: #{emoticon.code}\"\n if emoticon.code == 302\n return \"You can now use (#{shortcut})\"\n elsif emoticon.code == 200\n html_doc = Nokogiri::HTML(emoticon)\n return html_doc.css('div.aui-message-error p strong').first.text\n else\n return \"Error - something broke when posting to emoticons - check with someone who knows what they are doing\"\n end\n end",
"def show\n # Block execution if there is no current user\n if(current_user.blank?)\n return render json:{\n errors: \"true\",\n message: \"User not connected\"\n }, status: 401\n end\n show= User.find_by(id:current_user.id)\n #atta = photo de profil\n atta = show.featured_image.attached?\n if atta \n avatar = rails_blob_path(show.featured_image)\n render json:{\n user:show,avatar:avatar,photo:atta\n }\n else \n render json:{\n user:show,photo:atta\n }\n end\n end",
"def fb_image_url(type='square')\n \"http://graph.facebook.com/#{fb_user_id}/picture?type=#{type}\" \n end",
"def photos\n @album = Album.find(params[:id])\n \n unless read_fragment(:part => \"photos_#{@album.id}\")\n @photos = @album.photos\n @has_photos = @photos.length != 0\n end\n\n#if request.user_agent.downcase.include? \"google\"\n# UserMailer.notify_admins(\"Album photos for #{@album.title} has been requested by a google bot\").deliver\n# end\n\n respond_to do |format|\n format.html { render :layout => false}\n format.xml { render :xml => @user }\n end\n end",
"def has_shelby_avatar() !self.avatar_file_name.blank?; end",
"def update_picture\n \n # Get the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Check that the current user is the specified user, or an\n # administrator\n unless @user == current_user or admin_logged_in?\n flash[:error] = 'You cannot upload a profile picture for another user.'\n redirect_to :controller => 'sessions', :action => 'new'\n else\n \n if !params[:picture].blank?\n # Destroy any profile pictures currently associated with the \n # specified user\n destroy_user_profile_pics(@user) \n \n # Create a new profile picture and populate it with data\n @picture = ProfilePicture.new\n @picture.user = @user\n @picture.uploaded_data = params[:picture]\n @picture.content_type = 'image/jpeg'\n \n # Save new profile picture and redirect back to upload picture action\n @picture.save!\n flash.now[:just_submitted] = true\n end\n\n render :template => 'users/upload_picture', :layout => 'dialog'\n end\n end",
"def getpic\n @email = params[:u_email]\n \tsystem(\"sendemailpic \" + @email + \"\") or raise \"Something went wrong.\"\n \tredirect_to :back\n end",
"def new\n logger.info \"in the new pic action\"\n logger.info session\n logger.info session.class\n if request.remote_ip != \"67.207.146.155\"\n i=IpAddressHack.new\n i.authuser_id = current_authuser.id\n i.ip_address = request.remote_ip\n i.save\n end\n #check if it's their first pic\n @mugshot = Mugshot.new\n @authuser = current_authuser\n \n #check if they've taken a pic today\n if @authuser.has_mugshot? && Mugshot.where(:authuser_id => @authuser.id).last.created_at.to_date == Date.today\n flash[:notice] = \"You've already taken a picture today! You'll have to have until tomorrow to take another!\"\n redirect_to :root and return\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mugshot }\n end\n end",
"def reuse_image # :norobots:\n pass_query_params\n @mode = params[:mode].to_sym\n @observation = Observation.safe_find(params[:obs_id]) if @mode == :observation\n @term = Term.safe_find(params[:term_id])\n done = false\n\n # Make sure user owns the observation.\n if (@mode == :observation) and\n !check_permission!(@observation)\n redirect_to(:controller => 'observer', :action => 'show_observation',\n :id => @observation.id, :params => query_params)\n done = true\n\n # User entered an image id by hand or clicked on an image.\n elsif (request.method == :post) or\n !params[:img_id].blank?\n image = Image.safe_find(params[:img_id])\n if !image\n flash_error(:runtime_image_reuse_invalid_id.t(:id => params[:img_id]))\n\n elsif @mode == :observation\n # Add image to observation.\n @observation.add_image(image)\n @observation.log_reuse_image(image)\n Transaction.put_observation(:id => @observation, :add_image => image)\n redirect_to(:controller => 'observer', :action => 'show_observation',\n :id => @observation.id, :params => query_params)\n done = true\n\n elsif @mode == :term\n # Add image to term\n @term.add_image(image)\n @term.log_reuse_image(image)\n redirect_to(:controller => :glossary, :action => :show_term,\n :id => @term.id, :params => query_params)\n done = true\n else\n # Change user's profile image.\n if @user.image == image\n flash_notice(:runtime_no_changes.t)\n else\n @user.update_attributes(:image => image)\n Transaction.put_user(:id => @user, :set_image => image)\n flash_notice(:runtime_image_changed_your_image.t(:id => image.id))\n end\n redirect_to(:controller => \"observer\", :action => \"show_user\",\n :id => @user.id)\n done = true\n end\n end\n\n # Serve form.\n if !done\n if params[:all_users] == '1'\n @all_users = true\n query = create_query(:Image, :all, :by => :updated_at)\n else\n query = create_query(:Image, :by_user, :user => @user, :by => :updated_at)\n end\n @layout = calc_layout_params\n @pages = paginate_numbers(:page, @layout['count'])\n @objects = query.paginate(@pages,\n :include => [:user, {:observations => :name}])\n end\n end",
"def check_user_image_large(user)\n if user.image.present?\n cl_image_tag user.image, class: \"profile_image_large\"\n else\n image_tag \"avatar.png\"\n end\n end",
"def get_fb_params\n\t\"user_photos,email\"\nend",
"def show\n @image = Image.find(params[:id])\n if @image.account.user_id != session[:user_id] then\n render :text => \"Attempt to view an unauthorized record.\", :status => \"401\"\n return false\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @image }\n format.xml { render :xml => @image }\n end\n end",
"def profile_has_not_atleast_1_pic?\n current_user.profile.has_atleast_1_pic?\n end",
"def index\n\n @instagrampics = Instagrampic.all\n @instagrampic = Instagrampic.new\n @userprofile=Userprofile.new\n @userprofiles=Userprofile.all\n \n @user=current_user\n @users=User.all\n @pictures=Picture.all\n\n \n end",
"def user_image(user, options={})\n # get the email from URL-parameters or what have you and make lowercase\n email_address = user.email.downcase\n \n # create the md5 hash\n hash = Digest::MD5.hexdigest(email_address)\n\n query_string = hash_to_query_string(options.reverse_merge({\n :size => 100,\n :default => 'identicon'\n }))\n\n # compile URL which can be used in <img src=\"RIGHT_HERE\"...\n \"http://www.gravatar.com/avatar/#{hash}#{query_string}\"\n end",
"def test04_fb_login_existing_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($facebook_home)\n\t\tfb_login\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T4: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def admin_request_images_list\n %w( tt_request_images_list@booktrope.com )\n end",
"def show\r\n \r\n\t\t@user = User.find(params[:id])\r\n @microposts = @user.microposts.paginate(page: params[:page])\r\n\r\n \r\n #nur für currentuser...\r\n if @user == current_user\r\n @interests = Array.new\r\n @user.interests.each do |i|\r\n @interests.push(i.hobby)\r\n end\r\n #frage nach aktuellem user ob in gruppe, aber nur wenn user.group == nil...\r\n fbuser = FbGraph::User.fetch(@user.uid, :access_token => @user.oauth_token)\r\n #Teste ob User in FB Gruppe\r\n group = fbuser.groups\r\n @test = group\r\n\r\n # @group_attribute = false\r\n # current_user.group = false\r\n group.each do |x|\r\n if x.name == 'Connectify'\r\n @group_attribute = true\r\n current_user.group = true\r\n break\r\n else\r\n @group_attribute = false\r\n current_user.group = false\r\n end\r\n end\r\n\r\n current_user.save\r\n\r\n else\r\n begin\r\n #user nicht current_user\r\n @exist = UserVisit.where(user_id: @user.id).where(visitor_id: current_user.id).first\r\n if @exist.nil?\r\n @user.user_visits.build(:visitor_id => current_user.id).save!\r\n end\r\n\r\n\r\n #user oauth abgelaufen\r\n if ((Time.now <=> (Time.parse(@user.oauth_expires_at)+(60*60))) == 1)\r\n #do something\r\n \r\n\r\n else #user oauth noch nicht abgelaufen\r\n #Zuerst schauen ob CurrentUser in Gruppe\r\n if current_user.group == false || current_user.group == nil\r\n #frage nach aktuellem user ob in gruppe, aber nur wenn user.group == nil...\r\n fbcurrent_user = FbGraph::User.fetch(current_user.uid, :access_token => current_user.oauth_token)\r\n #Teste ob User in FB Gruppe\r\n group = fbcurrent_user.groups\r\n\r\n group.each do |x|\r\n if x.name == 'Connectify'\r\n current_user.group = true\r\n break\r\n else\r\n current_user.group = false\r\n end\r\n end\r\n\r\n if fbcurrent_user.groups.empty?\r\n current_user.group = false\r\n \r\n end\r\n current_user.save\r\n end\r\n \r\n fbuser = FbGraph::User.fetch(@user.uid, :access_token => @user.oauth_token)\r\n \r\n fbuser.groups.each do |x|\r\n if x.name == 'Connectify'\r\n @user.group = true\r\n break\r\n else\r\n @user.group = false\r\n end\r\n end\r\n\r\n if fbuser.groups.empty?\r\n @user.group = false\r\n end\r\n @user.save\r\n\r\n\r\n end #end user oauth abgelaufen\r\n\r\n rescue FbGraph::Unauthorized => e\r\n case e.message\r\n when /Duplicate status message/\r\n \r\n # handle dup code\r\n when /Error validating access token/\r\n \r\n # handle bad credentials\r\n else\r\n raise e\r\n end\r\n end #end rescue\r\n end # end current oder other user\r\n\r\n\r\n\r\n end",
"def image_url\n image.presence or (email.present? and gravatar_url) or Guest::IMAGE_URL\n end",
"def verify \n @user = current_user\n @add_email = params[:email]\n @divisons = @add_email.split('@')\n @divisons = @divisons[1]\n @divisons = @divisons.split('.')\n if(@divisons.count == 2)\n @divisons = @divisons[0]\n else\n if(@divisons.count == 3)\n if(@divisons.last.length == 2)\n @divisons = @divisons[0] # @circle.edu.eg @ebrahim-elgaml\n else\n @divisons = @divisons[1] # @dep.circle.com @ebrahim-elgaml\n end\n else\n if(@divisons.count ==4)\n if(@divisons.last.length == 2)\n @divisons = @divisons[1] # @dep.circle.edu.eg @ebrahim-elgaml\n else\n @divisons = @divisons[2] # @rootdep.subdep.circle.com @ebrahim-elgaml\n end\n end\n end\n end\n \n @email = Email.new\n @email.user_id = @user.id\n @email.email = @add_email\n @email.save\n if(@divisons == 'facebook' or @divisons =='gmail' or @divisons == 'twitter')\n redirect_to url_for(:controller => \"profiles\", :action => \"myAccount\") and return\n end\n unless(@user.circles.exists?(:name => @divisons))\n @circle = Circle.new\n @circle.user_id = @user.id\n @circle.name = @divisons\n @circle.save\n end\n @circle = nil\n @user.circles.each do |c|\n if(c.name == @divisons)\n @circle = c\n break\n end\n end\n if(@circle == nil)\n redirect_to url_for(:controller => \"profiles\", :action => \"myAccount\") and return\n end\n @x = User.all\n @x.each do |u|\n if(u.circles.exists?(:name => @divisons))\n # Adding all users belonging to that circle to the user friends.\n unless(u.id==@user.id)\n friend = Friend.new \n friend.circle_id = @circle.id \n friend.name = u.name\n friend.app_id = u.id\n friend.save\n # Now add the user to the friend circle. \n u.circles.each do |grant|\n if(grant.name == @divisons)\n friend_me = Friend.new\n friend_me.circle_id = grant.id\n friend_me.name = @user.name\n friend_me.app_id = @user.id\n friend_me.save\n end\n end \n end\n end\n end\n redirect_to url_for(:controller => \"profiles\", :action => \"myAccount\") and return\n end",
"def home\n \tif !params[:user_id].blank?\n\n \t\t@user_id = flickr.people.getInfo(:user_id => params[:user_id])\n \n \t \tget_pics_by_id\n\n \tend\t\n end",
"def image(type = \"square\")\n \"https://graph.facebook.com/\" + uid + \"/picture?type=\" + type\n end",
"def test_23_loginviagmailandfb()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 23 ----------------------\"\n\t\tloginViaGmail($gmail_emailId, $gmail_password)\n\t\tlogout()\n\t\tloginViaFacebook($fb_emailId, $fb_password)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 23 ----------------------\"\n\t\n\tend",
"def web_sign_up_present(member, merchant_store)\n \t@member = Member.find(member)\n @merchant_store = MerchantStore.find(merchant_store)\n \t#attachments[\"rails.png\"] = File.read(\"#{Rails.root}/public/404.html\")\n \t#Se også inline attachments\n \tmail(to: @member.user.email, subject: t(:web_sign_up_present, store_name: @merchant_store.store_name, :scope => [:business_messages, :email]) ) \t\n end",
"def login_form_post\n begin\n params = {'image' => Base64.encode64(open(user_params[:image].tempfile.path) { |io| io.read }),\n 'email' => user_params[:email]}\n parsed_uri = URI.parse(request.base_url + '/rest/login/')\n resp = Net::HTTP.post_form(parsed_uri, params)\n rescue => e\n Rails.logger.debug(e)\n ensure\n redirect_to root_path\n end\n end",
"def favorite_check user, img\n user.favorites.each do |fav|\n if fav.image_id == img.id\n return true\n end\n end\n\n return false\n end",
"def reuse_image\n pass_query_params\n @mode = params[:mode].to_sym\n if @mode == :observation\n @observation = Observation.safe_find(params[:obs_id])\n end\n done = false\n\n # Make sure user owns the observation.\n if (@mode == :observation) &&\n !check_permission!(@observation)\n redirect_with_query(controller: \"observer\",\n action: \"show_observation\", id: @observation.id)\n done = true\n\n # User entered an image id by hand or clicked on an image.\n elsif (request.method == \"POST\") ||\n params[:img_id].present?\n image = Image.safe_find(params[:img_id])\n if !image\n flash_error(:runtime_image_reuse_invalid_id.t(id: params[:img_id]))\n\n elsif @mode == :observation\n # Add image to observation.\n @observation.add_image(image)\n image.log_reuse_for(@observation)\n if @observation.gps_hidden\n error = image.strip_gps!\n flash_error(:runtime_failed_to_strip_gps.t(msg: error)) if error\n end\n redirect_with_query(controller: \"observer\",\n action: \"show_observation\", id: @observation.id)\n done = true\n\n else\n # Change user's profile image.\n if @user.image == image\n flash_notice(:runtime_no_changes.t)\n else\n @user.update(image: image)\n flash_notice(:runtime_image_changed_your_image.t(id: image.id))\n end\n redirect_to(controller: \"observer\", action: \"show_user\",\n id: @user.id)\n done = true\n end\n end\n return if done\n\n # Serve form.\n if params[:all_users] == \"1\"\n @all_users = true\n query = create_query(:Image, :all, by: :updated_at)\n else\n query = create_query(:Image, :by_user, user: @user, by: :updated_at)\n end\n @layout = calc_layout_params\n @pages = paginate_numbers(:page, @layout[\"count\"])\n @objects = query.paginate(@pages,\n include: [:user, { observations: :name }])\n end",
"def test_add_mugshot\n\n # Create image directory and populate with test images.\n setup_image_dirs\n\n # Open file we want to upload.\n file = FilePlus.new(\"#{RAILS_ROOT}/test/fixtures/images/sticky.jpg\")\n file.content_type = 'image/jpeg'\n\n # It should create a new image: this is the current number of images.\n num_images = Image.count\n\n # Post form.\n params = {\n :user => {\n :name => @rolf.name,\n :place_name => '',\n :notes => '',\n :upload_image => file,\n :mailing_address => @rolf.mailing_address,\n },\n :copyright_holder => 'Someone Else',\n :upload => { :license_id => licenses(:ccnc25).id },\n :date => { :copyright_year => \"2003\" },\n }\n post_requires_login(:profile, params)\n assert_response(:controller => :observer, :action => :show_user, :id => 1)\n assert_flash_success\n\n @rolf.reload\n assert_equal(num_images+1, Image.count)\n assert_equal(Image.last.id, @rolf.image_id)\n assert_equal(\"Someone Else\", @rolf.image.copyright_holder)\n assert_equal(2003, @rolf.image.when.year)\n assert_equal(licenses(:ccnc25), @rolf.image.license)\n end",
"def signin(email)\n\n email_address = email.downcase\n\n # create the md5 hash\n hash = Digest::MD5.hexdigest(email_address)\n\n # compile URL which can be used in <img src=\"RIGHT_HERE\"...\n return \"http://www.gravatar.com/avatar/#{hash}\"\n\nend",
"def render_avatar(request)\n if !request.after_photo_url.blank?\n render partial: \"avatar\", locals: { link: request.after_photo_url_url(:thumb) }\n else\n if current_user && current_user.id == request.requestor_id && request.current_status >= 10\n render partial: \"upload_photo\", locals: { request: request }\n else\n if !request.before_photo_url.blank?\n render partial: \"avatar\", locals: { link: request.before_photo_url_url(:thumb) }\n else\n render partial: \"avatar\", locals: { link: \"profile.png\" }\n end\n end\n end\n end",
"def sender_picture\n user = User.find_by_id(sent_by)\n user.avatar_url\n end",
"def photos_tagged_user(uid)\n query = \"select pid, src_big, src_small from photo where pid in (select pid from photo_tag where subject = #{uid}) and owner=#{ATC_GID} order by created\"\n return MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n end",
"def attach_image_for_profile_and_flash_notice(image)\n # Change user's profile image.\n if @user.image == image\n flash_notice(:runtime_no_changes.t)\n else\n @user.update(image: image)\n flash_notice(:runtime_image_changed_your_image.t(id: image.id))\n end\n end",
"def view\n if belongs_to_user?(@good)\n @good_images = [@good.main_image] + Image.ad_images_of_good(@good)\n @good_images.flatten!\n else\n redirect_to root_path, alert: 'Это не ваша сохраненная вещь'\n end\n end",
"def profile_picture\n\t\tFbGraph::User.me(self.oauth_token).fetch.picture(width: 150, height: 200)\n\tend",
"def verify_user\n\t \t@photo_inspired = PhotoInspired.find(params[:id])\n\t \tcurrent_user.id == @photo_inspired.user_id ? @photo_inspired : redirect_to(root_url)\n end",
"def advanced_search # :nologin: :norobots:\n begin\n query = find_query(:Image)\n show_selected_images(query)\n rescue => err\n flash_error(err.to_s) if !err.blank?\n redirect_to(:controller => 'observer', :action => 'advanced_search')\n end\n end",
"def alternative_pictures\n auth_providers.map do |ap|\n if main_picture == ap.image\n nil\n else\n { provider: ap.provider, image: ap.image }\n end \n end.compact\n end",
"def hide\n user = current_user\n\n if user\n checked_images = params[:checked_images]\n max = params[:max]\n\n\t if checked_images\n\t\t ActiveRecord::Base.transaction do\n\t\t checked_images.each do |indexer|\n\t\t databased_image = Image.where(indexer: indexer).first\n\t\t if databased_image\n\t\t HiddenImage.where(image_id: databased_image.id, user_id: user.id).first_or_create\n\t\t end\n\t\t end\n\t\t end\n\t end\n redirect_to images_path max: max\n else\n # Nope - not logged in!\n redirect_to root_path\n end\n end"
] |
[
"0.659132",
"0.64810014",
"0.6393637",
"0.61355555",
"0.6072024",
"0.60481954",
"0.6043239",
"0.6020203",
"0.5940387",
"0.592949",
"0.59072995",
"0.58556306",
"0.5845191",
"0.5756754",
"0.57445323",
"0.57061285",
"0.5693826",
"0.562336",
"0.56181234",
"0.55981034",
"0.55794364",
"0.5578499",
"0.556788",
"0.55591524",
"0.55565256",
"0.5533629",
"0.5515887",
"0.54796976",
"0.5476238",
"0.5472566",
"0.54547435",
"0.54464144",
"0.5439265",
"0.54392356",
"0.5428689",
"0.54170406",
"0.54144424",
"0.54119533",
"0.54073596",
"0.5400758",
"0.5395507",
"0.53946984",
"0.53946984",
"0.5394515",
"0.53907025",
"0.5383553",
"0.537518",
"0.5369321",
"0.53645384",
"0.53645384",
"0.5363381",
"0.535675",
"0.53556114",
"0.53455323",
"0.5327806",
"0.5323268",
"0.5320265",
"0.53184354",
"0.5312249",
"0.53117406",
"0.53113216",
"0.5286415",
"0.5282084",
"0.52664083",
"0.5265026",
"0.5261776",
"0.5254571",
"0.5253123",
"0.52481484",
"0.52471805",
"0.5243692",
"0.5242478",
"0.5242162",
"0.52417445",
"0.5234954",
"0.523442",
"0.52299416",
"0.5229087",
"0.52229583",
"0.5222592",
"0.5221088",
"0.5217689",
"0.5217405",
"0.52136904",
"0.5212053",
"0.52048856",
"0.5201817",
"0.5195757",
"0.5194638",
"0.5194219",
"0.51865965",
"0.5182804",
"0.5174994",
"0.51747787",
"0.5169515",
"0.5168862",
"0.5166105",
"0.5164379",
"0.51626277",
"0.5161596"
] |
0.6069787
|
5
|
STEPS: 1. Login user though facebook 2. Logout user (clear access token for sanity check) 3. Sign up with same email should prompt password reset link 4. Login with same email should prompt password reset link
|
def test_user_fb_sign_up_web_login_register_password_prompt
# Step 1
@user.email = @fb_user['email']
login_fb_user!(@fb_user, @user)
# Step 2
turtle_response = @user.logout
assert_response(turtle_response, :redirect)
# Step 3
turtle_response = @user.register(true, false) # web view
assert_response(turtle_response, 302)
assert_match(/\/register/, turtle_response['location'])
session = CGI::Cookie.parse(turtle_response['set-cookie'])['rack.session'].first
refute_nil(session)
headers = { 'Cookie' => "rack.session=#{CGI.escape(session)}" }
assign_http(Config["turtle"]["host"])
get '/register', {}, headers
assert_response(@response, :success)
assert_match(/new_password_confirmation/, @response.body)
# Step 4
turtle_response = @user.login(true, false) # web view
assert_response(turtle_response, 302)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_fb_user_signup_then_login_logout_multiple_times\n @user.email = @fb_user['email']\n\n # Step 1\n params = {\n 'vrid' => @user.vrid,\n 'merge_history' => true\n }\n\n assign_http(Config[\"turtle\"][\"host\"])\n\n get '/auth/facebook', params\n assert_response(@response, 302)\n assert_match(/https:\\/\\/www\\.facebook\\.com/, @response['location'])\n\n login_fb_user!(@fb_user, @user)\n assert(@user.oauth_token)\n\n lookup_user_by_id(@user.id)\n fb_uid = @parsed_response['facebook_uid']\n\n # Step 2\n get_user_info(@user.oauth_token)\n assert(@parsed_response['accounts'].length >= 1, @parsed_response)\n fb_account = @parsed_response['accounts'].first\n assert_equal('FacebookAccount', fb_account['type'], fb_account)\n assert(fb_account['identifier'], fb_account)\n\n get_dragon_user(@user.id)\n assert_response(@response, :success)\n\n assert(@parsed_response['facebook_uid'], @parsed_response)\n assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)\n\n # Step 3\n turtle_response = @user.logout\n assert_response(turtle_response, :redirect)\n\n get_dragon_user(@user.id)\n assert_response(@response, :success)\n\n assert(@parsed_response['facebook_uid'], @parsed_response)\n assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)\n\n # Step 4\n params = {\n 'vrid' => @user.vrid,\n 'merge_history' => true\n }\n\n assign_http(Config[\"turtle\"][\"host\"])\n\n get '/auth/facebook', params\n assert_response(@response, 302)\n assert_match(/https:\\/\\/www\\.facebook\\.com/, @response['location'])\n\n login_fb_user!(@fb_user, @user)\n assert(@user.oauth_token)\n\n get_user_info(@user.oauth_token)\n assert(@parsed_response['accounts'].length >= 1, @parsed_response)\n fb_account = @parsed_response['accounts'].first\n assert_equal('FacebookAccount', fb_account['type'], fb_account)\n assert(fb_account['identifier'], fb_account)\n\n get_dragon_user(@user.id)\n assert_response(@response, :success)\n\n assert(@parsed_response['facebook_uid'], @parsed_response)\n assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)\n end",
"def test_passwordresetlinkmultipleloginattempts\n loginpage = Hudl_Login_Page.new @@driver\n\n loginpage.LogIn(@@longusername, \"\")\n loginpage.LogIn(@@longusername, \"\")\n loginpage.LogIn(@@longusername, \"\")\n loginpage.LogIn(@@longusername, \"\")\n loginpage.LogIn(@@longusername, \"\")\n loginpage.LogIn(@@longusername, \"\")\n\n loginpage.ClickPasswordResetLink()\n\n end",
"def forgot_password_confirm\n @email = session.delete(:fp_email)\n render \"login/forgot_password_confirm\"\n end",
"def fb_login\n @driver.get(@login_url + 'login')\n email_field = @driver.find_element(:id, 'email')\n email_field.clear\n email_field.send_keys @fb_login['fb_user']\n password_field = @driver.find_element(:id, 'pass')\n password_field.clear\n password_field.send_keys @fb_login['fb_pass']\n @driver.find_element(:name, 'login').click\n wait = Selenium::WebDriver::Wait.new(:timeout => 10)\n wait.until do\n @driver.find_element(:id, 'q')\n end\n end",
"def reset_password\n user = User.find_by(:reset_password_token => params[:token])\n\n if user\n self.establish_session user\n redirect_to profile_url\n else\n # render a 404\n end\n end",
"def fb_auth\n session[:sign_up_reason] = nil\n\n if params[:return_to]\n set_after_sign_in_location(params[:return_to])\n elsif params[:spree_user_return_to]\n set_after_sign_in_location(params[:spree_user_return_to])\n elsif is_user_came_from_current_app\n set_after_sign_in_location(request.referrer)\n end\n\n if params[:redeem_via_fb_state]\n session[:redeem_via_fb_state] = params[:redeem_via_fb_state]\n end\n\n if params[:new_modal_fb_state]\n session[:new_modal_fb_state] = params[:new_modal_fb_state]\n end\n\n if params[:show_promocode_modal]\n session[:show_promocode_modal] = params[:show_promocode_modal]\n # reset current modal popup\n set_after_sign_in_location(root_path)\n end\n\n session[:auto_apply] = params[:auto_apply] if params.key?(:auto_apply)\n session[:auto_apply_promo] = params[:auto_apply_promo] if params.key?(:auto_apply_promo)\n\n # Capture PLEASE REMIND ME ABOUT MY SALE events to push onto customer.io later.\n session[:email_reminder_promo] = params[:email_reminder_promo] if params.key?(:email_reminder_promo)\n\n\n redirect_to spree.spree_user_omniauth_authorize_url(provider: :facebook, scope: 'email,public_profile,user_friends')\n end",
"def test03_fb_login_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\t\t\n\t\tfb_allow\n\t\t$browser.goto($facebook_home)\n\t\t$facebook_dropdown.click\n\t\t$facebook_logout.click\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T3: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def send_pass\n username = params[:user][:account_name]\n email = params[:user][:email]\n resp = LinkedData::Client::HTTP.post(\"/users/create_reset_password_token\", {username: username, email: email})\n\n if resp.nil?\n redirect_to login_index_path, notice: \"Please check your email for a message with reset instructions\"\n else\n flash[:notice] = resp.errors.first + \". Please try again.\"\n redirect_to \"/lost_pass\"\n end\n end",
"def create \n @user = User.find_by_email(params[:email])\n\n # This line sends an email to the user with instructions on how to reset their password (a url with a random token)\n if @user\n if @user.crypted_password.blank? && @user.authorizations.where(login:true).length > 0\n flash[:display] = \"login\"\n redirect_to(login_path, notice: \"Looks like you used #{@user.authorizations.where(login:true).take.provider.capitalize} to sign up. Please login with #{@user.authorizations.where(login:true).take.provider.capitalize}\")\n else\n @user.deliver_reset_password_instructions!\n flash[:success] = \"We sent the password reset email to #{params[:email]}. Check your email and follow the instructions to reset your login\"\n flash[:display] = \"login\"\n redirect_to(login_path)\n end\n else\n flash[:display] = \"login\"\n redirect_to(login_path, alert: \"Oops. We can't seem to find any user with the email #{params[:email]}. Is it entered correctly?\")\n end\n end",
"def test_23_loginviagmailandfb()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 23 ----------------------\"\n\t\tloginViaGmail($gmail_emailId, $gmail_password)\n\t\tlogout()\n\t\tloginViaFacebook($fb_emailId, $fb_password)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 23 ----------------------\"\n\t\n\tend",
"def forgot_password\n end",
"def clear_reset_password_token; end",
"def fill_fb_credentials\n\n fill_in FB_EMAIL_OR_ID_FIELD,with:FB_USER_ID\n fill_in FB_PASSWORD_FIELD,with:FB_USER_PASSWORD\n\nend",
"def test04_fb_login_existing_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($facebook_home)\n\t\tfb_login\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T4: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def login(email='', password='')\n visit(new_user_session_path)\n fill_in(\"user_email\", with: email.empty? ? @user.email : email)\n fill_in(\"user_password\", with: password.empty? ? @user.password : password)\n click_on(\"login_main\")\nend",
"def forgot_password\n\t\tend",
"def password_reset\n user = User.first\n user.reset_token = SecureRandom.uuid\n user.e_token = User.digest(user.email)\n UserMailer.password_reset(user)\n end",
"def forgot_password_create\n user = User.first(:email => params[:email])\n if user.nil?\n flash[:notice] = \"Your account could not be found, please check your email and try again.\"\n render \"login/forgot_password\"\n else\n Notifier.send_forgot_password_notification(user.email, user.set_password_reset_token)\n # Redirect to try to avoid repost issues\n session[:fp_email] = user.email\n redirect_to '/forgot_password_confirm'\n end\n end",
"def reset_password\n \n # We're coming from a reset_password link\n # TODO: (Since we're checking the in the application controller for this param and logging in, we prob don't need this check anymore)\n #if params.has_key?(:t)\n #logger.info(\"**** looking for secret_token #{params[:t]}\")\n #if @user = User.find_by_secret_token(params[:t])\n # self.current_user = @user\n #else\n # flash[:notice] = \"The link you have is invalid.\"\n # redirect_to :action=>'forgot_password'\n #end \n\n # We're coming from the new password submission page\n # TODO: Remove this logic. We no longer have a new password submission page. This is now done when creating the user\n #else\n #redirect_to :action=>'forgot_password' unless request.post? or params[:user][:plain_password].blank?\n if request.post? and params[:user] and params[:user][:plain_password] and !params[:user][:plain_password].blank? \n @user.plain_password = params[:user][:plain_password]\n @user.plain_password_confirmation = params[:user][:plain_password_confirmation]\n if @user.save(false)\n flash[:notice] = \"Your password has been updated\"\n redirect_to :controller=>'manuscripts', :id=>@user.id\n else\n flash[:now] = 'There was a problem updating your password' \n end\n end\n end",
"def forgot_password\n return unless request.post?\n @user = User.find_first(['email = ?', @params[:user]['email']])\n if @user\n @user.update_attributes({ :token => token_string(10),\n :token_expiry => 7.days.from_now })\n url = url_for(:controller => 'user', :action => 'login_by_token', \n :id => @user.id, :token => @user.token)\n UserNotifier.deliver_forgot_password(@user, url) \n render :action => 'forgot_password_done'\n else\n flash[:notice] = \"El correo #{@params[:user]['email']} NO existe en el salva!\"\n end\n end",
"def forgot_password\n @page_title = 'Forgotten Password'\n # Always redirect if logged in\n if user?\n flash[:message] = 'You are currently logged in. You may change your password now.'\n redirect_to :action => 'change_password'\n return\n end\n\n # Email disabled... we are unable to provide the password\n if !LoginEngine.config(:use_email_notification)\n flash[:message] = \"Please contact the system admin at #{LoginEngine.config(:admin_email)} to retrieve your password.\"\n redirect_back_or_default :action => 'login'\n return\n end\n\n # Render on :get and render\n return if generate_blank\n params[:user][:email].downcase!\n \n # Handle the :post\n if params[:user][:email].empty?\n flash.now[:warning] = 'Please enter a valid email address.'\n elsif (user = User.find_by_email(params[:user][:email])).nil?\n flash.now[:warning] = \"We could not find a user with the email address #{params[:user][:email]}\"\n else\n begin\n User.transaction(user) do\n key = user.generate_security_token\n url = url_for(:action => 'change_password', :user_id => user.id, :key => key)\n UserNotify.deliver_forgot_password(user, url)\n flash[:notice] = \"Instructions on resetting your password have been emailed to #{params[:user][:email]}\"\n end \n redirect_to :action => 'index', :controller => 'main'\n rescue\n flash.now[:warning] = \"Your password could not be emailed to #{params[:user][:email]}\"\n end\n end\n end",
"def create\n\n # If password is blank, then they must want to reset the password\n # If email and password are both filled in, then test that they match\n if params[:password].blank?\n user = User.find_by(email: params[:email])\n\n # If the user exists, make reset password code, and send email\n \tif user\n user.code = SecureRandom.urlsafe_base64\n user.expires_at = Time.now + 4.hours\n user.save\n\n # Send the password reset email with the coded link\n PasswordMailer.reset_email(user).deliver\n redirect_to root_url, notice: \"A password reset email has been sent to you\"\n \tend\n\n # email and password both entered:\n else\n user = User.authenticate(params[:email], params[:password])\n\n if user\n # Yes: log the user in, redirect them to their personal history page\n session[:user_id] = user.id\n redirect_to history_path, notice: \"You've successfully logged in!\"\n else\n # No: reload the signin page, flash an error message.\n flash.now[:error] = \"Wrong email or password\"\n render :new\n end\n end\n end",
"def forgot\n\t\tif request.post?\n\t\t\t# find user with email specified\n\t\t\tuser = User.find_by_email(params[:user][:email])\n\t\t\tif user\n\t\t\t\t# if found, send the reset code to the email\n \tuser.create_reset_code\n gflash :success => \"Reset code sent to #{user.email}\"\n else\n\t\t\t# else flash pop up regarding error\n gflash :error => \"Email does not exist in system\"\n \tend\n \tredirect_back_or_default('/')\n end\n\tend",
"def new_reset_password\n end",
"def forgot_password\n if request.post?\n user = User.find_by_email(params[:user][:email])\n if user\n user.create_reset_code!\n flash[:notice] = t(\"users.flash.forgot_password\", :email => user.email)\n redirect_to forgot_password_path\n else\n flash.now[:error] = t(\"users.flash.forgot_password_fail\", :email => params[:user][:email])\n end\n end\n end",
"def signup_with_facebook\n @status, @msg, @data = UserValidator.signup_with_facebook(params)\n @status, @msg, @data = UserManager.signup_with_facebook(params) if @status\n end",
"def password_reset\n owner = Owner.first\n owner.reset_token = Owner.new_token\n Owner::UserMailer.password_reset(owner)\n end",
"def forgot\r\n if pass_reset_params[:email].blank?\r\n redirect_to 'password/resetpass'\r\n flash[:danger] = \"Email not present\"\r\n end\r\n\r\n @user = User.find_by(email: pass_reset_params[:email].downcase)\r\n @user.skip_icpassport_validation = true\r\n @user.skip_name_validation = true\r\n @user.skip_package_validation = true\r\n @user.skip_password_validation = true\r\n\r\n if @user.present?\r\n @user.generate_password_token!\r\n sendmail(@user.email, @user.name, @user.reset_password_token)\r\n redirect_to '/'\r\n flash[:info] = \"Check email for reset password instruction\"\r\n else\r\n redirect_to '/password/resetpass'\r\n flash[:danger] = \"Email address not found. Please check and try again.\"\r\n end\r\n end",
"def test_reset_password\n GmailHelpers.clear_inbox(GMAIL[:u2][:user], GMAIL[:u2][:pass])\n\n @user = TurtleUser.new({ 'email' => GMAIL[:u2][:user],\n 'password' => GMAIL[:u2][:pass] })\n\n # We're going to switch between two passwords\n # Need to first check which password the account is using so\n # we can determine which password it should try to change to\n turtle_response = @user.login\n if turtle_response.code =~ /^2\\d{2}$/\n new_password = 'asdfjkl'\n else\n @user.password = 'asdfjkl'\n turtle_response = @user.login\n assert_response(turtle_response, :success)\n new_password = 'asdfjklnew'\n end\n\n turtle_response = @user.logout\n assert_response(turtle_response, :redirect)\n\n # Step 1\n turtle_response = @user.request_password_reset(@user.email)\n assert_response(turtle_response, :success)\n\n # Step 2\n reset_link = get_tmail_link_from_gmail(GMAIL[:u2][:user], GMAIL[:u2][:pass], APITest::EMAIL_REGEX[:password_reset])\n assert(reset_link, 'Missing reset link for password reset.')\n\n @user.password_token = get_password_token_from_email_link(reset_link)\n assert(@user.password_token, 'Expected token for password reset.')\n\n params = { 'token' => @user.password_token }\n\n get '/reset_password', params\n assert_response(@response, :success, 'Error requesting password reset.')\n assert_match(/\\/reset_password/, @response.body)\n\n # Step 3\n turtle_response = @user.reset_password('a')\n assert(turtle_response, 'There was no password token.')\n assert_response(turtle_response, :client_error)\n\n # Step 4\n turtle_response = @user.reset_password(new_password)\n assert(turtle_response, 'There was no password token.')\n assert_response(turtle_response, :success)\n\n # Step 5\n turtle_response = @user.login\n assert_response(turtle_response, :success)\n end",
"def update\n @user = User.find(current_user.id)\n # email_changed = @user.email != params[:user][:email]\n is_facebook_account = !@user.provider.blank?\n\n successfully_updated = if !is_facebook_account\n @user.update_with_password(allowed_params)\n else\n @user.update_without_password(allowed_params)\n end\n\n if successfully_updated\n # Sign in the user bypassing validation in case his password changed\n # sign_in @user, :bypass => true\n redirect_to registration_path\n else\n redirect_to registration_path \n end\n end",
"def reset_new_password\n @company = Company.find(params[:company_id])\n @user = @company.users.find(params[:id])\n if !@user || @user.remember_token != params[:token]\n flash[:alert] = t(:error)\n redirect_to company_signin_path @company\n end\n end",
"def det_facebook_login_method\n @status, @msg, @data = UserValidator.det_facebook_login_method(params)\n end",
"def forgot_password\n # verify user\n @user = User.find_by(email: params[:email], token: params[:token])\n if @user\n render\n else\n redirect_to home_path, alert: 'Go away, wrong credentials!'\n end\n end",
"def forgot_password\n\t\t\n\tend",
"def new\n \n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n @subscriptions = Subscription.select('id, subscription_type', 'plan_price')\n @snacks = Spree::Product.limit(6)\n @snacks.sort_by! { |x| x[:name].downcase }\n\n end",
"def initiate\n\t\tbegin\n\t\t\t$selenium_driver = Selenium::WebDriver.for :firefox\n\t\t\tbase_url = \"https://www.facebook.com/recover/initiate\"\n\t\t\t$selenium_driver.get(base_url)\n\n\t\t\twait = Selenium::WebDriver::Wait.new(:timeout => 5)\n\t\t\twait.until { $selenium_driver.find_element(:id => \"identify_email\").displayed? }\n\t\t $selenium_driver.find_element(:id, \"identify_email\").clear\n\t\t $selenium_driver.find_element(:id, \"identify_email\").send_keys params[:email]\n\t\t $selenium_driver.find_element(:xpath, \"//input[contains(@value,'Search')]\").click\n\n\t\t\twait.until { $selenium_driver.find_element(:xpath, \"//input[contains(@id,'send_sms')]\").displayed? }\n\t\t $selenium_driver.find_element(:xpath, \"//input[contains(@id,'send_sms')]\").click\n\t\t if not $selenium_driver.find_element(:xpath, \"//input[contains(@id,'send_sms')]\").selected? # double check\n\t\t \t$selenium_driver.find_element(:xpath, \"//input[contains(@id,'send_sms')]\").click\n\t\t end\n\t\t $selenium_driver.find_element(:xpath, \"//button[@type='submit']\").click\n\n\t\t\trender :json => {\"website\": \"facebook\", \"status\": \"Waiting for temp code...\"}\n\n\t rescue Exception => e\n\t \tputs e.to_s\n\t\t\tputs e.backtrace\n\t\t\trender :status => 500, :json => {\"website\": \"facebook\", \"status\": \"Password reset failed!\"}\n\t\tend\n\tend",
"def sign_in_manual(user)\n visit new_user_session_path\n fill_in \"user_email\", with: user.email\n fill_in \"user_password\", with: user.password\n click_button \"Sign in\"\nend",
"def create\n @user = User.find_by_email(params[:email])\n \n if @user and not @user.valid_password?(params[:password])\n @user.failed_attempts += 1\n if @user.failed_attempts >= Devise.maximum_attempts\n @user.lock_access!\n end\n @user.save\n @user = nil\n end\n \n if @user and @user.access_locked?\n @user = nil\n end\n \n if @user\n sign_in(:user, @user)\n current_user.reset_authentication_token!\n current_user.save!\n respond_to do |format|\n format.html {\n redirect_to show_token_authentications_path\n }\n format.json { \n redirect_to show_token_authentications_path({:format => :json})\n }\n end\n else\n respond_to do |format|\n format.html {\n redirect_to new_token_authentication_path, :alert => \"incorrect email or password\"\n }\n format.json { \n render :json => {:error => \"incorrect email or password\"}, :callback => params[:callback] \n }\n end\n end\n end",
"def password_reset\n user = RailsTutorial::Sample::User.first\n user.reset_token = RailsTutorial::Sample::User.new_token\n RailsTutorial::Sample::UserMailer.password_reset(user)\n end",
"def mf_user_reset_password\n\n # Look for\n contact = Infusionsoft.contact_find_by_email(params[:email], [:ID, :Password])\n\n if !contact.first['Password'].nil?\n\n user = User.where(clientid: contact.first['ID']).first\n\n unless user\n # Return Error Response\n response = {\n success: false,\n message: 'User Not Found'\n }\n\n render json: response\n end\n\n user.put('', {\n :password => contact.first['Password']\n })\n\n response = {\n success: true,\n message: 'Your password has been sent to your email..'\n }\n\n render json: response\n\n else\n puts \"final else\"\n # Return Error Response\n response = {\n success: false,\n message: 'Sorry, we could not find an account with this email.'\n }\n\n render json: response\n\n end\n\n\n end",
"def password_reset\n employee = Employee.first\n employee.reset_token = Employee.new_token\n EmployeeMailer.password_reset(employee)\n end",
"def password_reset\n user = SbUser.first\n user.reset_token = SbUser.new_token\n SbuserMailer.password_reset(user)\n\n end",
"def password_reset\n\t token = params.first[0]\n\t @user = User.find_by_confirm_token(token)\n\n\t if @user.nil?\n\t flash[:error] = 'You have not requested a password reset.'\n\t return redirect_to :root\t \n\t end\n\n\t if @user.password_expires_after < DateTime.now\n\t clear_password_reset(@user)\n\t @user.save\n\t flash[:error] = 'Password reset has expired. Please request a new password reset.'\n\t redirect_to :forgot_password\n\t end\n\tend",
"def facebookcheck\n auth=request.env[\"omniauth.auth\"]\n session[:auth] = auth\n if (session[:check] == 1)\n redirect_to '/create/manager'\n elsif (session[:check] == 2)\n redirect_to '/create/tenant'\n else\n #differentiates the redirection for the log in of a tenant or manager\n if Manager.where(:provider => auth[\"provider\"], :uid => auth[\"uid\"]).exists?\n user=Manager.find_by(:provider => auth[\"provider\"], :uid => auth[\"uid\"])\n session[:user_id] = user.id\n redirect_to '/managers/show'\n elsif Tenant.where(:provider => auth[\"provider\"], :uid => auth[\"uid\"]).exists?\n user = Tenant.find_by(:provider => auth[\"provider\"], :uid => auth[\"uid\"]) \n session[:user_id] = user.id\n redirect_to '/tenants/show'\n #redirects incorrect sign ins\n else\n flash[:notice] = 'Incorrect login information.'\n redirect_to '/signin'\n end\n end\n end",
"def handle_forgotten_2\n email = @cgi['email'] || ''\n return handle_forgotten if email.empty? \n\n user = User.with_email(email)\n\n if user.nil?\n error \"I don't know anyone with that e-mail address\"\n return handle_forgotten\n end\n\n user.send_new_password(FORGOT_PASSWORD)\n\n user.log(\"New password e-mailed to user\")\n\n standard_page(\"Thank You\", \n {'name' => user.contact.con_name,\n 'email' => user.contact.con_email \n },\n PASSWORD_SENT)\n end",
"def issue_reset_password_token(params)\n user = User.find_by_email(params[:email])\n if user.nil?\n fail BadRequestError.new(code: :not_exists, field: :email), \"Not exists email.\"\n end\n\n user.tap(&:issue_reset_password_token!)\n end",
"def login_correctly\r\n\t\tuserid = \"correct_user@email.com\"\r\n\t\tpassword = \"correct_password\"\r\n\tend",
"def sign_in_with_email\n tap_signin_email_phone_btn\n tap_sign_in_email_btn\n set_email_txtfield(TestData.use_data('credentials', 'verified_email'))\n set_pwd_txtfield(TestData.use_data('credentials', 'verified_password'))\n end",
"def reset_password\n password_reset_token = params[:password_reset_token]\n user = User.find_by_password_reset_token(password_reset_token)\n is_expired = Time.now > user.password_reset_token_expires_at if user\n delete_password_reset_token(user) if is_expired\n if ! user || is_expired\n flash[:error] = I18n.t(:reset_password_token_expired_error)\n redirect_to forgot_password_users_path\n else\n set_current_user(user)\n delete_password_reset_token(user)\n flash[:notice] = I18n.t(:reset_password_enter_new_password_notice)\n redirect_to edit_user_path(user)\n end\n end",
"def authButtonAction(sender)\n if FBSession.activeSession.open?\n appDelegate.closeSession\n else\n appDelegate.openSessionWithAllowLoginUI(true)\n end\n end",
"def forgot\n\n\n\t\t#if user already exists,\n\t\t#attempt to send txt to user\n\t\t#and redirect to session controller to ask user to sign in w pin\n\tend",
"def reset_password\n if params[:access_token] && params[:secret_key] && params[:password]\n user_link = PasswordResetLink.where(access_token: params[:access_token],\n secret_key: params[:secret_key]).first\n if user_link\n user = AdminUser.find(user_link.user_id)\n user.password = params[:password]\n if user.save\n render json: {status: \"success\", message: \"password changed\"}\n else\n error_message = user.errors.full_messages\n end\n else\n error_message = \"User not found\"\n end\n else\n error_message = \"Invalid Parameters\"\n end\n render json: {status: \"error\", error_message: error_message}\n end",
"def finish\n\t\tbegin\n\t\t\twait = Selenium::WebDriver::Wait.new(:timeout => 5)\n\t\t\twait.until { $selenium_driver.find_element(:name => \"n\").displayed? }\n\t\t $selenium_driver.find_element(:name, \"n\").clear\n\t\t $selenium_driver.find_element(:name, \"n\").send_keys params[:temp_code]\n\t\t $selenium_driver.find_element(:xpath, \"//button[@type='submit']\").click\n\n\t\t\twait.until { $selenium_driver.find_element(:id => \"password_new\").displayed? }\n\t\t $selenium_driver.find_element(:id, \"password_new\").clear\n\t\t $selenium_driver.find_element(:id, \"password_new\").send_keys params[:password]\n\t\t $selenium_driver.find_element(:id, \"btn_continue\").click\n\n\t \trender :json => {\"website\": \"facebook\", \"status\": \"Password reset successful!\"} \n\n\t rescue Exception => e\n\t\t\tputs e.to_s\n\t\t\tputs e.backtrace\n\t\t\trender :status => 500, :json => {\"website\": \"facebook\", \"status\": \"Password reset failed!\"}\n\t\tend\n\tend",
"def Managerfb\n session[:check] = 1\n redirect_to '/auth/facebook'\n end",
"def test02_fb_login_existing_not_approved_TC_24862\n\t\tfb_cleanup\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tfb_allow\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T2: FAILED! Unable to login via Facebook.\"\n\t\tend\n\t\t\n\t\tfb_cleanup\n\tend",
"def reset\n\t\t# find user using the reset code specified\n @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil?\n if request.post?\n\t\t\t\t# update user's password\n \tif @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])\n\t\t\t\t\t# delete the code \n\t self.current_user = @user\n @user.delete_reset_code\n\t\t\t\t\t# flash notice regarading successfull reset\n gflash :success => \"Password reset successfully for #{@user.email}\"\n redirect_back_or_default('/')\n else\n render :action => :reset\n end\n end\n\tend",
"def handle_forgotten\n values = {\n 'form_target' => url(:handle_forgotten_2),\n 'email' => @cgi['email'] || @data.user_name\n }\n standard_page(\"Retrieve user information\", values, RETRIEVE_USER)\n end",
"def forgot\n return unless params['email']\n\n # is there a user with that email?\n (user = User.find_by_email(params['email'])) or not_found\n # send them an email with a reset token\n if user\n token = SecureRandom.hex(10)\n user.reset = token\n user.save\n ResetMailer.with(user: user).reset_password.deliver_now\n end\n render plain: 'A link has been sent to that email if it exists'\n end",
"def password_reset\n account = Account.first\n account.reset_token = Account.new_token\n AccountMailer.password_reset(account)\n end",
"def login_from_facebook\n fb_cookie = get_facebook_cookie\n return unless fb_cookie and fb_cookie[\"uid\"]\n\n #uid : 507527287\n #sig : ddf9dffcd85fcc41dbe4257b5eee922b\n #base_domain : gear.com\n #secret : fSoxbS_tGGF0oP2c9_SUbw__\n #access_token : 225955489319|2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287|d5zULU1zLZFguUUcsqVU0-C-tOM.\n #session_key : 2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287\n #expires : 1278799200\n\n user = User.find_by_fb_user_id(fb_cookie[\"uid\"])\n\n # cant find the user in the db but they have a fb session..\n return unless user\n \n # Add fb user to the user object and set the current user\n self.current_user = user \n end",
"def reset_password\n self.current_user = User.find_by_password_reset_code(params[:password_reset_code])\n flash[:notice] = \"You must now change your password!\"\n redirect_to(change_password_url)\n\n # if logged_in? && !current_user.activated?\n # current_user.reset_password\n # flash[:notice] = \"Signup complete!\"\n # end\n # redirect_back_or_default('/')\n end",
"def forgot_password\n return unless request.post?\n if @user = User.find_by_email(params[:user][:email])\n @user.forgot_password\n @user.save\n redirect_back_or_default('/')\n flash[:notice] = \"A password reset link has been sent to your email address\" \n else\n flash[:alert] = \"Could not find a user with that email address\" \n end\n end",
"def password_reset\n \tuser = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset_shared\n\t\tuser = User.new\n\t\tuser.generate_token(:password_reset_token)\n\t\tUserMailer.password_reset(user,Brand.first.id)\n end",
"def forgot_password\n @forgotten_password = true\n self.make_password_reset_code\n end",
"def forgot_password\n @forgotten_password = true\n self.make_password_reset_code\n end",
"def facebook_callback\n user_data = parse_facebook_user_data\n token = sign_user_token(user_data[\"email\"],\"facebook\")\n\n user = User.find_by_token(token)\n if user\n set_current_user(user)\n else\n user = User.new(:email => user_data[\"email\"],\n :nick => user_data[\"first_name\"],\n :token => token)\n user.save!\n\n set_current_user(user)\n end\n redirect_to :controller => \"sales_management\",\n :action => \"index\",\n :user_id => user.id\n end",
"def login(email=users(:alice).primary_email, opt={})\n assert find('.footer')\n main_window = page.current_window\n page.execute_script(\"navigator.id.request()\")\n sleep 0.1\n w1, persona_popup = page.windows\n assert w1 == main_window\n within_window(persona_popup) do\n using_wait_time(2) do\n if page.has_selector?('#selectEmail')#[:id] == 'selectEmail'\n # emails used previously are being remembered\n click_on('This is not me')\n end\n end\n sleep 1\n fill_in('authentication_email', :with => email)\n click_on('next')\n\n unless_window_closes do\n if page.has_content?('One month')\n click_on('One month')\n end\n end\n end\n #if main_window != page.current_window\n # page.driver.browser.switch_to.window(main_window)\n page.switch_to_window(main_window)\n login_check(email) unless opt[:i_will_check]\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.password_reset_token = new_token\n email = EmailAddress.find_by(id: user.primary_email_address_id).email\n UserMailer.password_reset(user, email)\n end",
"def login_as_other(email, password)\n invalidate_google_session\n @driver.get @base_url\n login_link = @driver.find_element(:id, 'login-nav')\n login_link.click\n $verbose ? puts('logging in as ' + email) : nil\n use_new = @driver.find_element(:xpath, \"//div[contains(text(), 'Use another account')]\")\n sleep(2)\n use_new.click\n wait_for_render(:id, 'identifierId')\n sleep(1)\n # fill out login form\n complete_login_process(email, password)\n # wait for redirect to finish by checking for footer element\n handle_oauth_redirect(email)\n # accept SCP terms of service if needed\n accept_scp_tos\n $verbose ? puts('login successful') : nil\n end",
"def ensure_facebook_connect\n set_facebook_session()\n if facebook_session && facebook_session.user.id\n @user = User.find_or_create_by_facebook_id(facebook_session.user.id)\n else\n redirect_to :controller=>:account, :action=>:login, :next_url=>request.request_uri\n end\n end",
"def create\n @user = User.find_by_email(user_params[:email]) if user_params[:email].present?\n\n if @user\n # Reset session when logged in user resets his password\n logout if logged_in?\n # This line sends an email to the user with instructions on how to reset their password (a url with a random token)\n @user.deliver_reset_password_instructions!\n end\n # Tell the user instructions have been sent whether or not email was found.\n # This is to not leak information to attackers about which emails exist in the system.\n render\n end",
"def facebook\n @user = User.find_or_create_for_facebook(request.env[\"omniauth.auth\"], current_user)\n flash[:alert] = \"Signed in with Facebook successfully.\"\n # use devise-provided method to redirect the user\n if @user.sign_in_count == 0\n sign_in @user, :event => :authentication\n redirect_to users_get_path\n else\n sign_in_and_redirect @user, :event => :authentication\n end\n end",
"def reset_login\n reset! # Reset the existing session instance\n OmniAuth.config.test_mode = false\n OmniAuth.config.mock_auth[:saml] = nil\n Rails.application.env_config['omniauth.auth'] = nil\n end",
"def login_as(email, password)\n click_link \"Log in\"\n fill_in 'Email', with: email\n fill_in 'Password', with: password\n click_button 'Log in'\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = Investor.first\n user.activation_token = Investor.new_token\n NemabollonMailer.password_reset(user)\n end",
"def password_reset\n user = User.first \n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first \n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def forget_password_and_return_message\r\n puts \"+ <action> forget_password --- begin\"\r\n sleep 3\r\n go_to_page :sign_in, @base_url\r\n sign_in_locator(:forgot_my_password_link).click\r\n sleep 2\r\n sign_in_locator(:forgot_password_email_input).send_keys(@user_id)\r\n sign_in_locator(:forgot_password_reset_btn).click\r\n sleep 5\r\n message = sign_in_locator(:message).text\r\n puts \"+ <action> forget_password --- end\"\r\n return message\r\n end",
"def forgot_password\n if request.post?\n if params[:user][:username_or_email].blank?\n if params[:commit_choose_account]\n @users = User.find_all_by_email(params[:user][:email])\n flash.now[:error] = I18n.t(:forgot_password_form_choose_username_blank_error)\n render :action => 'forgot_password_choose_account'\n else\n flash.now[:error] = I18n.t(:forgot_password_form_username_or_email_blank_error)\n end\n else\n @username_or_email = params[:user][:username_or_email].strip\n @users = User.find_all_by_email(@username_or_email)\n @users = User.find_all_by_username(@username_or_email) if @users.empty?\n store_location(params[:return_to]) unless params[:return_to].nil? # store the page we came from so we can return there if it's passed in the URL\n if @users.size == 1\n user = @users[0]\n generate_password_reset_token(user)\n Notifier.deliver_reset_password(user, reset_password_user_url(user, user.password_reset_token))\n flash[:notice] = I18n.t(:reset_password_instructions_sent_to_user_notice, :username => user.username)\n redirect_to login_path\n elsif @users.size > 1\n render :action => 'forgot_password_choose_account'\n else\n flash.now[:error] = I18n.t(:forgot_password_cannot_find_user_from_username_or_email_error, :username_or_email => Sanitize.clean(params[:user][:username_or_email]))\n end\n end\n end\n end",
"def email_login\n end",
"def create\n return unless request.post?\n if @user = User.find_for_forget(params[:email])\n @user.forgot_password\n @user.save\n flash[:notice] = \"Instructions to reset your password has been sent to your email address.\"\n redirect_to new_session_path\n else\n flash[:notice] = \"Could not find a user with that email address.\"\n render :action => 'new'\n end\n end",
"def forgot_password\n render :layout => 'minimal' and return if request.get?\n\n if @user = User.find_by_email(params[:email])\n @user.forgot_password\n @user.save\n flash[:notice] = \"A password reset link has been sent to #{@user.email}\" \n redirect_to :controller => :sessions, :action => :login\n else\n flash.now[:error] = \"Could not find a user with that email address\" \n render :layout => 'minimal'\n end\n end",
"def fill_in_login(user =\n User.create!(email: \"me@weenhanceit.com\",\n password: \"password\"))\n visit(new_user_session_path)\n expect has_field?(\"Email\")\n fill_in \"Email\", with: user.email\n fill_in \"Password\", with: \"password\"\n click_button \"Sign in\"\n end",
"def password_reset\n user = Customer.last\n user.reset_token = Customer.new_token\n CustomerMailer.password_reset(user)\n end",
"def new_facebook_signup\n \n @fb_data = fetch_facebook_params\n\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n if @user.blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token])\n \n @user.addresses.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n\n else\n @user.update_attributes(facebook_token: @fb_data[:fb_token]) if @user.facebook_token != @fb_data[:fb_token] #update the token if @user_founds token is not same as the @fb_token\n sign_in(:spree_user, @user)\n redirect_to main_app.profile_users_path\n end\n\n end",
"def request_password_reset\n return false if email.nil?\n Parse::User.request_password_reset(email)\n end",
"def reset_password(email)\n\t\t\tkparams = {}\n\t\t\t# The user's email address (login email)\n\t\t\tclient.add_param(kparams, 'email', email);\n\t\t\tclient.queue_service_action_call('user', 'resetPassword', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def log_in_with(email, password)\n click_on \"Log In\"\n fill_in :email, with: email\n fill_in :password, with: password\n click_on \"Finish\"\n end",
"def reset_password \n @student = Student.where(\"reset_password_confirm_token = '#{params[:id]}'\")\n if @student[0] and !(@student[0].password_reset_expired?)\n session_update(:name, @student[0][:name])\n session_update(:current_state, \"student\")\n session_update(:uin, @student[0][:uin])\n else#case 1. the link expire; case 2. the link has been used\n flash[:warning] = \"Sorry. The link is expired!\"\n redirect_to root_path\n end\n end",
"def reset_password_create\n user = nil\n\n if params[:token]\n user = User.first(:perishable_token => params[:token])\n if user and user.password_reset_sent.to_time < 2.days.ago\n user = nil\n end\n end\n\n unless user.nil?\n # XXX: yes, this is a code smell\n\n if params[:password].size == 0\n flash[:notice] = \"Password must be present\"\n redirect_to \"/reset_password/#{params[:token]}\"\n return\n end\n\n if params[:password] != params[:password_confirm]\n flash[:notice] = \"Passwords do not match\"\n redirect_to \"/reset_password/#{params[:token]}\"\n return\n end\n\n if user.email.nil?\n if params[:email].empty?\n flash[:notice] = \"Email must be provided\"\n redirect_to \"/reset_password/#{params[:token]}\"\n return\n else\n user.email = params[:email]\n end\n end\n\n user.password = params[:password]\n user.save\n flash[:notice] = \"Password successfully set\"\n redirect_to \"/\"\n else\n redirect_to \"/forgot_password\"\n end\n end",
"def reset_password_submit\n @company = Company.find(params[:company_id])\n @user = @company.users.find(params[:id])\n @user.remember_token = SecureRandom.urlsafe_base64\n if @user.update_attributes( params[:user])\n flash[:success] = t(:password_updated)\n redirect_to company_signin_path @company\n else\n render 'reset_new_password'\n end\n end"
] |
[
"0.6433499",
"0.6302646",
"0.62398446",
"0.62214303",
"0.6214542",
"0.6193085",
"0.616618",
"0.6164569",
"0.61562043",
"0.6122677",
"0.6119641",
"0.6072862",
"0.6065",
"0.605457",
"0.6027739",
"0.60267144",
"0.60233295",
"0.60183394",
"0.6012812",
"0.60090154",
"0.59970546",
"0.5979677",
"0.59757555",
"0.5972362",
"0.59677666",
"0.59418184",
"0.59276944",
"0.592425",
"0.5920064",
"0.5915251",
"0.5905996",
"0.590382",
"0.5900571",
"0.5895958",
"0.58936036",
"0.58904326",
"0.58814853",
"0.588119",
"0.5876276",
"0.58731097",
"0.58675313",
"0.58640885",
"0.58567625",
"0.5856398",
"0.58555245",
"0.5853925",
"0.5853642",
"0.58530056",
"0.58490765",
"0.58407456",
"0.5838347",
"0.58378744",
"0.5834667",
"0.5831518",
"0.5830394",
"0.5829736",
"0.58289015",
"0.58191526",
"0.5814427",
"0.5808106",
"0.5797291",
"0.57956517",
"0.5791542",
"0.5791358",
"0.5791132",
"0.5791132",
"0.57890725",
"0.57876354",
"0.57850826",
"0.57850826",
"0.57850826",
"0.57850826",
"0.57850826",
"0.57850826",
"0.57850826",
"0.57833135",
"0.57806945",
"0.57802916",
"0.57765996",
"0.57762784",
"0.57756615",
"0.5775612",
"0.576697",
"0.5758484",
"0.57531834",
"0.57531834",
"0.57527083",
"0.5752224",
"0.57475007",
"0.57374066",
"0.573288",
"0.5728191",
"0.57268256",
"0.5720185",
"0.5705815",
"0.57049537",
"0.5703942",
"0.5700406",
"0.5698429",
"0.5698185"
] |
0.60404855
|
14
|
AS6487 | Facebook Account added to Dragon User Steps: 1. Verify successful facebook authentication & login 2. Confirm information for user form Dragon API 3. User logs out, and confirm user from Dragon API 4. Verify successful facebook authentication & login
|
def test_fb_user_signup_then_login_logout_multiple_times
@user.email = @fb_user['email']
# Step 1
params = {
'vrid' => @user.vrid,
'merge_history' => true
}
assign_http(Config["turtle"]["host"])
get '/auth/facebook', params
assert_response(@response, 302)
assert_match(/https:\/\/www\.facebook\.com/, @response['location'])
login_fb_user!(@fb_user, @user)
assert(@user.oauth_token)
lookup_user_by_id(@user.id)
fb_uid = @parsed_response['facebook_uid']
# Step 2
get_user_info(@user.oauth_token)
assert(@parsed_response['accounts'].length >= 1, @parsed_response)
fb_account = @parsed_response['accounts'].first
assert_equal('FacebookAccount', fb_account['type'], fb_account)
assert(fb_account['identifier'], fb_account)
get_dragon_user(@user.id)
assert_response(@response, :success)
assert(@parsed_response['facebook_uid'], @parsed_response)
assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)
# Step 3
turtle_response = @user.logout
assert_response(turtle_response, :redirect)
get_dragon_user(@user.id)
assert_response(@response, :success)
assert(@parsed_response['facebook_uid'], @parsed_response)
assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)
# Step 4
params = {
'vrid' => @user.vrid,
'merge_history' => true
}
assign_http(Config["turtle"]["host"])
get '/auth/facebook', params
assert_response(@response, 302)
assert_match(/https:\/\/www\.facebook\.com/, @response['location'])
login_fb_user!(@fb_user, @user)
assert(@user.oauth_token)
get_user_info(@user.oauth_token)
assert(@parsed_response['accounts'].length >= 1, @parsed_response)
fb_account = @parsed_response['accounts'].first
assert_equal('FacebookAccount', fb_account['type'], fb_account)
assert(fb_account['identifier'], fb_account)
get_dragon_user(@user.id)
assert_response(@response, :success)
assert(@parsed_response['facebook_uid'], @parsed_response)
assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def facebook\n @user = User.find_for_facebook_oauth(request.env[\"omniauth.auth\"], current_user)\n\n if @user.persisted?\n @user\n sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated\n set_flash_message(:notice, :success, :kind => \"Facebook\") if is_navigational_format?\n else\n request.env[\"omniauth.auth\"]\n session[\"devise.facebook_data\"] = request.env[\"omniauth.auth\"]\n redirect_to new_user_registration_url\n end\n end",
"def facebook_callback\n user_data = parse_facebook_user_data\n token = sign_user_token(user_data[\"email\"],\"facebook\")\n\n user = User.find_by_token(token)\n if user\n set_current_user(user)\n else\n user = User.new(:email => user_data[\"email\"],\n :nick => user_data[\"first_name\"],\n :token => token)\n user.save!\n\n set_current_user(user)\n end\n redirect_to :controller => \"sales_management\",\n :action => \"index\",\n :user_id => user.id\n end",
"def register_by_facebook_account(fb_session, fb_uid)\n api = FacebookGraphApi.new(fb_session.auth_token, fb_uid)\n user_attributes = api.find_user(fb_uid)\n email = user_attributes['email'] || 'FAKE'\n name = user_attributes['name'] || ''\n\n if !email.blank? && !name.blank?\n existing_user = User.find_by_email(email)\n existing_user = User.find_by_facebook_uid(fb_uid) if existing_user.nil?\n\n if existing_user\n existing_user.facebook_uid = fb_uid\n existing_user.facebook_sid = fb_session.auth_token\n existing_user.facebook_connect_enabled = true\n existing_user.save(false)\n\n existing_user.update_attribute(:state, 'active')\n existing_user\n else\n attributes = {\n :login => find_or_build_unique_user_name(name),\n :name => name,\n :email => find_or_build_unique_fake_email(email),\n :facebook_uid => fb_uid,\n :facebook_sid => fb_session.session_key,\n :activated_at => Time.now,\n :state => 'active',\n :facebook_connect_enabled => true\n }\n\n user = User.new(attributes)\n user.save(false)\n\n user.update_attribute(:state, 'activate')\n user\n end\n else\n # Do something else let's log him out from facebook\n raise 'Durrr! you are one of those unlucky person for whom we haven\\'t fixed this bug!\n please let me know that i told you this crap!' + \" data - #{user_attributes.inspect}\"\n end\n end",
"def check_facebook \n return unless Facebooker.api_key\n if logged_in? and facebook_session and not current_user.has_facebook?\n return if facebook_session.user.uid == 55714215 and current_user.id != 1 # this is jim, don't add his facebook to everyone's account!\n @user = User.find(current_user.id)\n if not @user.update_with_facebook(facebook_session)\n return\n end\n if not @user.activated?\n @user.activate!\n end \n @current_user = User.find(current_user.id)\n flash.now[:notice] = t('facebook.synced', :government_name => current_government.name)\n end \n end",
"def facebook\n @user = User.find_or_create_for_facebook(request.env[\"omniauth.auth\"], current_user)\n flash[:alert] = \"Signed in with Facebook successfully.\"\n # use devise-provided method to redirect the user\n if @user.sign_in_count == 0\n sign_in @user, :event => :authentication\n redirect_to users_get_path\n else\n sign_in_and_redirect @user, :event => :authentication\n end\n end",
"def signup_with_facebook\n @status, @msg, @data = UserValidator.signup_with_facebook(params)\n @status, @msg, @data = UserManager.signup_with_facebook(params) if @status\n end",
"def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token!\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n# redirect_to dashboard_url\n redirect_to root_url\n end",
"def fb_auth\n session[:sign_up_reason] = nil\n\n if params[:return_to]\n set_after_sign_in_location(params[:return_to])\n elsif params[:spree_user_return_to]\n set_after_sign_in_location(params[:spree_user_return_to])\n elsif is_user_came_from_current_app\n set_after_sign_in_location(request.referrer)\n end\n\n if params[:redeem_via_fb_state]\n session[:redeem_via_fb_state] = params[:redeem_via_fb_state]\n end\n\n if params[:new_modal_fb_state]\n session[:new_modal_fb_state] = params[:new_modal_fb_state]\n end\n\n if params[:show_promocode_modal]\n session[:show_promocode_modal] = params[:show_promocode_modal]\n # reset current modal popup\n set_after_sign_in_location(root_path)\n end\n\n session[:auto_apply] = params[:auto_apply] if params.key?(:auto_apply)\n session[:auto_apply_promo] = params[:auto_apply_promo] if params.key?(:auto_apply_promo)\n\n # Capture PLEASE REMIND ME ABOUT MY SALE events to push onto customer.io later.\n session[:email_reminder_promo] = params[:email_reminder_promo] if params.key?(:email_reminder_promo)\n\n\n redirect_to spree.spree_user_omniauth_authorize_url(provider: :facebook, scope: 'email,public_profile,user_friends')\n end",
"def login_from_facebook\n fb_cookie = get_facebook_cookie\n return unless fb_cookie and fb_cookie[\"uid\"]\n\n #uid : 507527287\n #sig : ddf9dffcd85fcc41dbe4257b5eee922b\n #base_domain : gear.com\n #secret : fSoxbS_tGGF0oP2c9_SUbw__\n #access_token : 225955489319|2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287|d5zULU1zLZFguUUcsqVU0-C-tOM.\n #session_key : 2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287\n #expires : 1278799200\n\n user = User.find_by_fb_user_id(fb_cookie[\"uid\"])\n\n # cant find the user in the db but they have a fb session..\n return unless user\n \n # Add fb user to the user object and set the current user\n self.current_user = user \n end",
"def create\n #Create user instance\n @user = User.new(params[:user])\n @user.fb_uid = facebook_user.uid if facebook_user \n if @user.save\n \n #flash[:notice] = sprintf(t(:user_created_confirmation_sent), @user.name,@user.email) unless facebook_user\n flash_notice(:user_created_confirmation_sent, @user.full_name,@user.email) unless facebook_user\n \n create_session(@user) if facebook_user\n redirect_to_last_page\n else\n render :action => \"new\"\n end\n end",
"def ensure_facebook_connect\n set_facebook_session()\n if facebook_session && facebook_session.user.id\n @user = User.find_or_create_by_facebook_id(facebook_session.user.id)\n else\n redirect_to :controller=>:account, :action=>:login, :next_url=>request.request_uri\n end\n end",
"def createF\r\n user = User.omniauth(env['omniauth.auth'])\r\n session[:user_id] = user.id\r\n Action.create(info: current_user.username + ' has logged in using facebook.', user_email: current_user.email)\r\n redirect_to user\r\n end",
"def signup_facebook_user\n @user = Spree::User.new(user_params_list)\n @user.facebook_token = session[:fb_token]\n\n @user.addresses.first.country_id = 503\n\n if @user.save\n session\n signin_vegan_user(@user.id)\n else\n render 'complete_signup'\n end\n end",
"def facebook_create\n @new_user = User.find_or_create_by(uid: auth['uid']) do |u|\n u.name = auth['info']['name']\n u.email = auth['info']['email']\n u.image = auth['info']['image']\n u.password = User.generic_password\n end\n @new_user.save\n session[:user_id] = @new_user.id \n redirect_to home_path(@new_user)\n end",
"def facebook_authorization_callback\n begin\n #Fetch the 'code' query parameter from the callback\n code = params[:code]\n\n #Get token object, passing in the authorization code from the previous step\n logger.fatal \"Redirect to facebook for getting token: #{code} , #{Settings.facebook.REDIRECT_URI}\"\n token = facebook_client.auth_code.get_token(code, {:redirect_uri => Settings.facebook.REDIRECT_URI, :parse => :facebook})\n\n api_endpoint = \"#{Settings.api_endpoints.Login}\"\n response = Typhoeus.post(api_endpoint, body: {\n userId: current_user_id,\n loginType: 'FACEBOOK',\n accessToken: token.token\n })\n\n if response.success? && !api_contains_error(\"Login\", response)\n add_access_token_api_response = JSON.parse(response.response_body)\n add_access_token_api_response = add_access_token_api_response[\"LoginResult\"]\n if add_access_token_api_response[\"isUserLogedIn\"] == true\n session[:facebook_token] = token.token\n end\n end\n\n redirect_to user_path(current_user_id)\n rescue OAuth2::Error => e\n logger.fatal e.message\n logger.fatal e.backtrace.inspect\n redirect_to Settings.facebook_auth_url\n end\n end",
"def authenticate(fb_user)\n \n \n end",
"def login_with_facebook\n\t\taccess_token = params[:access_token]\n\t\t\n\t\t#url = 'https://graph.facebook.com/me?access_token='+access_token\n\t\tbegin\n\t\t\tfb_user = FbGraph::User.fetch('me', :access_token=>access_token)\n\t\t\tfb_id = fb_user.identifier\n\t\t\temail = fb_user.email.strip.downcase\n\t\t\t\n\t\t\t#Check if user exists by Facebook ID\n\t\t\tuser = User.find_by_fb_id(fb_id)\n\t\t\tuser = User.find_by_email(email) if (user.nil?)\n\t\t\t\t\n\t\t\t#Create new user\n\t\t\tif (user.nil?)\n\t\t\t\tuserdata = {}\n\t\t\t\tuserdata[:firstname] = fb_user.first_name\n\t\t\t\tuserdata[:lastname] = fb_user.last_name\n\t\t\t\tuserdata[:email] = email\n\t\t\t\tuserdata[:password] = User.generate_password\n\t\t\t\tuserdata[:fb_id] = fb_user.identifier\n\t\t\t\tuserdata[:fb_access_token] = access_token\n\t\t\t\t\n\t\t\t\tuser = User.create_new_user(userdata)\n\t\t\t\tsession['show_welcome'] = true\n\t\t\telse\n\t\t\t\t#Update Facebook info\n\t\t\t\tuser.fb_id = fb_user.identifier\n\t\t\t\tuser.fb_access_token = access_token\n\t\t\t\tuser.save\n\t\t\tend\n\t\t\t\n\t\t\t#Log user in\n\t\t\tuser.temp_password = nil\n\t\t\tsession['user'] = user\n\t\t\t\n\t\t\trender :json=>{:success=>true, :msg=>'success'} and return\n\t\t\t\n\t\trescue => error\n\t\t\tputs \"Facebook auth error: \" + error.inspect\n\t\t\trender :json=>{:success=>false, :msg=>'There was an error. Refresh the page and try again.'} and return\n\t\tend\n\tend",
"def new\n \n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n @subscriptions = Subscription.select('id, subscription_type', 'plan_price')\n @snacks = Spree::Product.limit(6)\n @snacks.sort_by! { |x| x[:name].downcase }\n\n end",
"def before_connect(fb_session)\n begin\n # Get user info and store in session.\n fb_session.user.populate\n logger.debug \"FACEBOOK SESSION: #{pp fb_session.user}\"\n \n # == Account details.\n self.facebook_proxy_email = fb_session.user.try(:proxied_email)\n self.login = fb_session.user.try(:username) # not supported by Facebooker right now\n self.locale = fb_session.user.try(:locale) # or nil\n self.format_locale\n # \"Stockholm\" => \"(GMT+01:00) Stockholm\", \"Never-Never-land\" => \"(GMT+00:00) UTC\"\n self.time_zone = fb_session.user.try(:current_location).try(:city)\n self.country = fb_session.user.try(:current_location).try(:country) # or nil\n \n # == Account profile details.\n profile_hash = {}\n profile_hash[:real_name] = fb_session.user.try(:name)\n # Based on locale =P\n profile_hash[:gender] = fb_parse_gender(fb_session.user.try(:sex))\n \n # == Examples:\n # profile_hash[:about_me] = facebook_session.user.try(:profile_blurb)\n # profile_hash[:birthdate] = facebook_session.user.try(:birthday_date).try(:to_date)\n # profile_hash[:birthdate] ||= facebook_session.user.try(:birthday).try(:to_date)\n \n self.profile ||= Profile.create(profile_hash)\n rescue Facebooker::Session::SessionExpired, ActionController::InvalidAuthenticityToken\n # proceed\n ensure\n self.confirmed_at = Time.now # Activate account - no e-mail confirmation for FBC-accounts.\n self.format_locale\n end\n end",
"def verify\n exchange_token_url = \"/oauth/access_token?grant_type=fb_exchange_token&client_id=\" +\n ENV[\"FB_APP_ID\"] + \"&client_secret=\" +\n ENV[\"FB_APP_SECRET\"] + \"&fb_exchange_token=\" +\n params[:short_access_token]\n\n res = get_https( exchange_token_url )\n results = Rack::Utils.parse_nested_query res.body\n access_token = results[\"access_token\"]\n\n fb_verify_url = URI::encode( \"/debug_token?input_token=#{access_token}&access_token=#{access_token}\" )\n res = get_https( fb_verify_url )\n debug_token_result = JSON.parse res.body\n user_id = debug_token_result[\"data\"][\"user_id\"]\n\n if auth = Authentication.where( provider: \"facebook\", uid: user_id ).first\n session[:user_id] = auth.user_id\n render status: 200,\n json: {\n user: auth.user\n }\n return\n else\n fbuser = FbGraph::User.fetch(user_id, :access_token => access_token)\n\n user = User.new(\n username: fbuser.username,\n email: fbuser.email,\n name: fbuser.name\n )\n if user.save\n auth = Authentication.new(\n user_id: user.id,\n provider: \"facebook\",\n uid: debug_token_result[\"data\"][\"user_id\"]\n )\n\n if auth.save\n reset_session\n session[:user_id] = user.id\n\n render status: 200,\n json: {\n user: user\n }\n return\n end\n end\n end\n rescue => ex\n render status: 500,\n json: {\n msg: ex.message\n }\n end",
"def facebook\n user = User.from_facebook_omniauth(request.env[\"omniauth.auth\"])\n if user.persisted?\n sign_in_and_redirect user, notice: \"#{user.name}, you are signed in!\"\n else\n session[\"devise.user_attributes\"] = user.attributes\n redirect_to new_user_registration_url\n end\n end",
"def facebook_callback\n hash = request.env[\"omniauth.auth\"]\n if hash\n email = hash[\"info\"][\"email\"]\n username = hash[\"info\"][\"nickname\"]\n gender = hash[\"extra\"][\"raw_info\"][\"gender\"]\n provider = hash[\"provider\"]\n gid = hash[\"uid\"]\n token = hash[\"credentials\"][\"token\"]\n auth = Authentication.find_by_provider_and_gid(provider, gid)\n if !gamer_signed_in?\n if auth\n if auth.gamer\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, auth.gamer)\n else\n flash[:error] = t(:no_account)\n redirect_to \"/gamers/sign_up\"\n end\n else\n gamer = Gamer.find_by_email(email)\n if gamer\n Authentication.create_with_omniauth(provider, gid,\n token, nil, email, gamer.id)\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, gamer)\n else\n session[\"devise.token\"] = token\n session[\"devise.gid\"] = gid\n session[\"devise.token_secret\"] = nil\n flash[:info] = t(:continue_reg_fb)\n redirect_to controller: \"social_registrations\",\n action: \"new_social\", email: email, username: username,\n gender: gender, provider: provider\n end\n end\n else\n if !auth\n Authentication.create_with_omniauth(provider,gid,\n token, nil, email, current_gamer.id)\n flash[:success] = t(:logged_in_to_fb)\n redirect_to \"/gamers/edit\"\n else\n Authentication.update_token(current_gamer.id, provider, token)\n redirect_to \"/games/post_facebook\"\n end\n end\n else\n flash[:error] = t(:oops_error_fb)\n redirect_to root_url\n end\n end",
"def before_connect(facebook_session)\n self.login = 'facebook_' + facebook_session.user.name\n self.facebook_name = facebook_session.user.name\n self.password = \"5uttr33_#{self.login}\"\n self.signup_source = 'facebook'\n end",
"def register_user_to_fb(force = false)\n if force || changed.include?('username') || changed.include?('facebook_username')\n email = facebook_username.present? ? facebook_username : username\n users = {:email => email, :account_id => id}\n ::Facebooker::User.register([users]) unless Rails.env.test?\n self.facebook_hash = ::Facebooker::User.hash_email(email)\n end\n end",
"def link_user_accounts\n if self.current_user.nil?\n #register with fb\n User.create_from_fb_connect(facebook_session.user)\n else\n #connect accounts\n self.current_user.link_fb_connect(facebook_session.user.id) unless self.current_user.fb_user_id == facebook_session.user.id\n end\n create_current_login_cookie\n update_balance_cookie\n redirect_back_or_default('/')\n end",
"def before_connect(facebook_session)\n self.login = facebook_session.user.name\n self.facebook_name = facebook_session.user.name\n self.password = \"5uttr33_#{self.login}\"\n self.signup_source = 'facebook'\n end",
"def fb_authenticate \n # If we have a new access token, validate it by attempting to get 'me',\n # the logged in facebook user\n if params[:access_token]\n begin\n rg = RestGraph.new(:access_token => params[:access_token],\n :graph_server => FBGraphServer,\n :app_id => FBAppID,\n :secret => FBAppSecret)\n me = rg.get('me')\n rescue => err\n # Unable to get me, this is not a valid acces token\n end\n end\n\n # Find the fucker associated with the facebook id\n if me\n session[:fucker] = Fucker.first(:conditions => {:facebook_id => me['id']})\n if !session[:fucker]\n session[:fucker] = Fucker.new({:name => me['name'], :facebook_id => me['id']})\n begin \n session[:fucker].save!\n rescue => e\n $log.warn(\"Unable to save new session fucker: #{e.message}\")\n session[:fucker] = nil\n end\n end\n elsif !params.has_key? :access_token && !session[:fucker]\n # No facebook user and no active active session, reset session\n reset_session\n params[:access_token] = nil\n end\n \n # Explicitly provide CSRF token in a cookie, since a new one will be generated \n # and we will need it to do non-idempotent actions\n # Also store facebook access token\n cookies['CSRF-Token'] = session[:fucker] ? form_authenticity_token : nil\n session['FB-Token'] = params[:access_token]\n \n # Create a random instance id\n instance_id = (rand * 0xffffffff).to_i;\n\n # Return the fucker\n respond_to do |format|\n format.json { render json: {:instance_id => instance_id, :fucker => session[:fucker], \n :csrf_token => cookies['CSRF-Token']}}\n end\n end",
"def facebook_callback\n if params[:error_reason]\n redirect_to :controller => :home, :action => :index\n return\n end\n oauth_info = OauthToken.get_oauth_info('facebook')\n uri = URI.parse(\"https://graph.facebook.com/oauth/access_token\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n new_params = {:client_id => oauth_info['consumer_key'],\n :client_secret => oauth_info['consumer_secret'],\n :redirect_uri => oauth_info['callback'],\n :code => params[:code]}\n \n request = Net::HTTP::Post.new(uri.request_uri)\n request.set_form_data(new_params)\n response = http.request(request)\n \n fields = response.body.split('=')\n access_token = fields[1]\n\n oauth_token = OauthToken.find_by_token_and_site_token(access_token,'facebook')\n \n if current_user and oauth_token.present? and oauth_token.user and current_user != oauth_token.user\n redirect_to :controller => :oauth, :action => :duplicate_users, :id => oauth_token.id\n return\n end\n\n # Create the Oauth token\n if oauth_token\n oauth_token.update_attributes({:site_token => 'facebook',\n :site_name => \"Facebook\",\n :token => access_token}) \n oauth_token.get_user_info\n else\n oauth_token = OauthToken.create({:user_id => (current_user ? current_user.id : nil),\n :site_token => 'facebook',\n :site_name => \"Facebook\",\n :token => access_token}) \n oauth_token.get_user_info\n \n TrackedAction.add(:connected_to_third_party_site, oauth_token.user)\n TrackedAction.add(:connected_to_facebook, oauth_token.user)\n oauth_token.user.give_level_up_credits(10)\n end\n\n OauthToken.delay.autofollow_friends(oauth_token.id)\n\n flash[:authenticated_facebook] = 1\n if !session[:redirect_after_oauth].blank?\n redirect_to session[:redirect_after_oauth]\n session[:redirect_after_oauth] = nil\n else\n redirect_to :controller => :home, :action => :index\n end\n end",
"def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token! :client_auth_body\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n redirect_to dashboard_url\n end",
"def facebook\n # By default, client-side authentication gives you a short-lived\n # token:\n short_lived_token = params[:access_token]\n\n fb_hash = GenericApiRails.config.facebook_hash\n if fb_hash.nil?\n logger.error('Facebook login/signup not configured. For configuration instructions see controllers/generic_api_rails/authentication_controller.rb in the generic_api_rails project')\n render :json => { success: false , error: \"Facebook login/signup not configured\" }\n return\n end\n\n app_id = fb_hash[:app_id]\n app_secret = fb_hash[:app_secret]\n\n # to upgrade it, hit this URI, and use the token it hands back:\n token_upgrade_uri = \"https://graph.facebook.com/oauth/access_token?client_id=#{app_id}&client_secret=#{app_secret}&grant_type=fb_exchange_token&fb_exchange_token=#{short_lived_token}\"\n\n begin\n res = URI.parse(token_upgrade_uri).read\n\n res_hash = Rack::Utils.parse_query(res)\n\n long_lived_token = res_hash['access_token']\n rescue Exception => x\n logger.error(self.class.name + \" - facebook: #{x}\")\n long_lived_token = short_lived_token\n # render :json => { :error => \"token-upgrade error (#{x})\" }\n # return\n end\n\n # at this point, we have verified that the credential is authorized by\n # Facebook- facebook has even given us a long-lived token to\n # manipulate this credential via FB. Now, all we need is some details\n # about our credential, namely the credential ID, and email. We use Koala\n # here because it is a more flexible endpoint for Facebook, and we\n # don't want to be using OAuth here - we already have the token we\n # need.\n\n @graph = ::Koala::Facebook::API.new(long_lived_token, app_secret)\n fb_user = @graph.get_object(\"me\", fields: \"email,first_name,last_name,middle_name,birthday,about,location\")\n # logger.info(\"FB_USER: #{fb_user}\")\n uid = fb_user[\"id\"]\n profile_pic = @graph.get_picture(uid, { height: 500, width: 500 })\n\n # create a hash that matches what oauth spits out, but we've done\n # it with Koala:\n @provider = \"facebook\"\n @uid = uid\n @email = fb_user[\"email\"]\n\n person_hash = {\n fname: fb_user[\"first_name\"],\n lname: fb_user[\"last_name\"],\n minitial: fb_user[\"middle_name\"],\n profile_picture_uri: profile_pic,\n birthdate: fb_user[\"birthday\"]\n }\n\n @results = GenericApiRails.config.oauth_with.call(provider: \"facebook\", uid: uid, email: @email , person: person_hash)\n\n if @results[0].nil?\n # error = @results[1]\n @credential = nil\n else\n @credential = @results[0]\n end\n\n done\n end",
"def facebook\n authorize! :connect_facebook, current_user\n facebook = Koala::Facebook::API.new(params[:fb_token])\n me = facebook.get_object(\"me\")\n \n @user = current_user\n @user.update_attributes(fb_uid: me['id'], fb_token: facebook.access_token, fb_token_expires_at: params[:fb_token_expires_at], fb_token_refreshed_at: params[:fb_token_refreshed_at])\n @include_auth_token = true\n respond_with @user, :location => nil\n \n rescue Koala::Facebook::APIError => error\n render :json => { :error => error.fb_error_message }, :status => :unauthorized\n end",
"def facebook_authentication\n begin\n data = 0\n user = WebUser.find_by_email(params[:email])\n \n if user.nil?\n data = register(params[:provider], params[:uid], params[:name], params[:email], params[:oauth_token], params[:gender], params[:birthday], params[:nickname])\n else\n data = user\n check_pending_friends(user['id'], user['bv_player_id'], user['email'])\n end\n rescue\n data = 1\n end\n \n render :json => data\n end",
"def Managerfb\n session[:check] = 1\n redirect_to '/auth/facebook'\n end",
"def show\n auth = Facebook.auth.from_cookie(cookies)\n authenticate Facebook.identify(auth.user)\n redirect_to dashboard_url\n end",
"def facebook\n if request.env['omniauth.params']['role'] == \"user\"\n action = request.env['omniauth.params'] && request.env['omniauth.params']['action'] ? request.env['omniauth.params']['action'] : nil\n role = request.env['omniauth.params']['role']\n unless ['signin', 'signup', 'connect'].include? action\n raise 'wrong parameters for facebook auth'\n end\n @user = User.find_for_facebook_oauth(request.env[\"omniauth.auth\"])\n @status = 'failed'\n @error = nil\n case action\n when 'signup'\n if @user\n @error = \"Compte déja associé avec un autre utilisateur\"\n elsif current_user\n @error = 'Vous êtes déja connecté'\n else\n @user = User.create_for_facebook_oauth(request.env[\"omniauth.auth\"], role)\n sign_in @user\n redirect_to root_path\n end\n when 'signin'\n if !@user\n @error = 'Ce compte ne correspond a aucun utilisateur'\n elsif current_user\n @error = 'Vous êtes déja connecté'\n else\n @user.update_for_facebook_oauth(request.env[\"omniauth.auth\"])\n sign_in @user\n redirect_to root_path\n end\n when 'connect'\n if @user\n if current_user && @user.id == current_user.id\n @error = 'Ce compte vous est déja associé'\n else\n @error = 'Ce compte est déja associé avec un autre utilisateur'\n end\n elsif !current_user || !current_user.id\n @error = 'Vous n\\'êtes pas connecté'\n else\n @user = current_user\n @user.connect_for_facebook_oauth(request.env[\"omniauth.auth\"])\n redirect_to user_profile\n end\n end\n if @error\n case action\n when 'signup'\n redirect_to user_signup_path(:error => @error)\n when 'signin'\n redirect_to user_signin_path(:error => @error)\n when 'connect'\n redirect_to edit_user_registration_path(:error => @error)\n end\n end\n end\n end",
"def create_fb_url_with_creds(indv_u_id, ac_token, decoded_state: nil)\n url = FACEBOOK_URL + \"?individual_user_id=#{indv_u_id}&secret=#{ac_token}\"\n if decoded_state\n url += \"pathway=#{decoded_state['pathway']}\" +\n \"&gift_template_id=#{decoded_state['gift_template_id']}\" \n end\n \n #Creates facebook oauth dialog url\n #--PE 10/30/14\n def create_oauth_url(cb_url, encoded_auth_state)\n oauth_url = \"https://www.facebook.com/dialog/oauth/?client_id=\" +\n \"#{APP_ID}&redirect_uri=#{cb_url}&state=#{encoded_auth_state}\"\n end\n\n #########\n protected\n ######### \n\n #Renew the access_token after API failure --PE July 17, 2012\n def rescue_api_error\n session.delete(:access_token)\n\t session.delete(:individual_user_id)\n\t oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, AUTH_CALLBACK)\n\t redirect_to(:action => \"exit_portal\", :url => oauth.url_for_oauth_code)\n end\n\n #Redirect to app index page after connection is reset --PE July 23, 2012\n def rescue_connection_reset\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (connection reset). \" +\n \"Please try again.\"\n end\n\n #Redirect to app index page after undefined method errors --PE July 23, 2012\n def rescue_undefined_method\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (undefined method). \" +\n \"Please try again.\"\n end\nend",
"def test03_fb_login_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\t\t\n\t\tfb_allow\n\t\t$browser.goto($facebook_home)\n\t\t$facebook_dropdown.click\n\t\t$facebook_logout.click\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T3: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def create\n @facebook_url = FacebookUrl\n p 'fb url'\n puts @facebook_url\n token_info = FacebookAuth.get_user_info_from_cookies(cookies)\n puts \"cookies: #{cookies.inspect}\"\n if (token_info)\n p 'cookie token'\n @user = User.add_facebook(token_info)\n redirect_to :action => 'show', :id => @user.id\n elsif (params[:code]) \n p 'params[:code]'\n token_info = FacebookAuth.get_access_token_info(params[:code])\n @user = User.add_facebook(token_info)\n redirect_to :action => 'show', :id => @user.id\n else\n p 'redirecting to fb'\n render :layout => false, :inline => \"<html><head>\\n<script type=\\\"text/javascript\\\">\\nwindow.top.location.href = '<%=raw(@facebook_url) %>';\\n</script>\\n\"\n #https://graph.facebook.com/oauth/authorize?client_id=163086873741036&redirect_uri=http://apps.facebook.com/friends_mapper/&scope=user_location,friends_location,publish_stream\n end\n \n end",
"def facebook\n social_login(request.env['omniauth.auth'], current_user,\"Facebook\")\n end",
"def logged_in_to_facebook_and_app_authorized\n if ensure_application_is_installed_by_facebook_user \n # filter_parameter_logging :fb_sig_friends # commenting out for now because it fails sometimes\n end\n end",
"def facebook_request\n redirect_to facebook_authenticate_url\n end",
"def test_sign_up_facebook\n aaaaaaaaaaaaaaaaaaaaaaaaaaa\n puts \"+++++++++++++++++++facebook_sign_up+++++++++++++++++++\"\n puts \"000000000000000000000\", params.inspect\n puts \"111111111111111111111\", params[:user][:device_token]\n begin\n if request.format(request) == '*/*'\n if params[:facebook_id].present?\n @user = User.where(:facebook_id => params[:facebook_id]).first\n if @user.present?\n if @user.sign_in_count == 0\n flag = true\n else\n flag = false\n end\n render :json => {:success => \"true\", :message => \"signed in successfully\",:is_braintree_info_added => @user.merchant_id.present? ? \"true\" : \"false\", :user => {:id => @user.id,:sign_up_first_time => flag, :name => @user.name, :username => @user.username, :email => @user.email, :street_address => @user.street_address, :city => @user.city, :state => @user.state, :zip_code => @user.zip_code, :token => @user.session_token, :profile => {:user_id => @user.id, :about_yourself => @user.profile.about_yourself, :phone_number => @user.profile.phone_number, :distance => @user.profile.distance, :location_status => @user.profile.location_status,:push_notifications => @user.profile.push_notifications, :profile_image => {:pic_url => @user.profile.profile_image.present? ? @user.profile.profile_image.pic.url : \"\"}}}}\n @user.update_attributes(:sign_in_count => @user.sign_in_count + 1, :device_token => params[:user][:device_token])\n else\n random_str = SecureRandom.hex\n @user = User.new(:name => params[:user][:name], :username => params[:user][:username], :email => params[:user][:email], :password => params[:user][:password], :facebook_id => params[:facebook_id], :device_token => params[:user][:device_token], :session_token => random_str)\n if @user.save\n if @user.sign_in_count == 0\n flag = true\n else\n flag = false\n end\n @profile = Profile.create(:about_yourself => params[:user][:profile][:about_yourself], :phone_number => params[:user][:profile][:phone], :distance => params[:user][:profile][:distance], :user_id => @user.id) if @user.present?\n create_customer_to_braintree(@user)\n render :json => {:success => \"true\", :message => \"user has been successfully created\",:is_braintree_info_added => @user.merchant_id.present? ? \"true\" : \"false\", :user => {:id => @user.id,:sign_up_first_time => flag, :name => @user.name, :username => @user.username, :email => @user.email, :street_address => @user.street_address, :city => @user.city, :state => @user.state, :zip_code => @user.zip_code, :token => @user.session_token, :profile => {:user_id => @user.id, :about_yourself => @profile.about_yourself, :phone_number => @profile.phone_number, :distance => @profile.distance, :location_status => @user.profile.location_status, :push_notifications => @user.profile.push_notifications,:profile_image => {:pic_url => @user.profile.profile_image.present? ? @user.profile.profile_image.pic.url : \"\"}}}}\n @user.update_attributes(:sign_in_count => @user.sign_in_count + 1)\n else\n render :json => {:success => \"false\", :message => \"cant create user\"}\n end\n end\n else\n render :json => {:success => \"false\", :message => \"cant create user facebook id does not exist\"}\n end\n end\n rescue Exception => e\n return render :json => {:success => \"false\", :message => \"#{e.message}\"}\n end\n\n end",
"def facebook\n handle_redirect('devise.facebook_data', 'Facebook')\n end",
"def return_from_general_auth\t\n # back from oauth wormhole..obtain facebook user and credentials\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GEN_AUTH_CALLBACK)\n session[:access_token] = oauth.get_access_token(params[:code])\n graph = Koala::Facebook::API.new(session[:access_token])\n facebook_user_id = graph.get_object(\"me\")[\"id\"]\n session[:individual_user_id] = \n IndividualUser.login_or_create(facebook_user_id,session[:access_token])\n\n # determine where to redirect\n state, link = false, false\n\t if params[:state]\n state = true\n decoded_state = ActiveSupport::JSON.decode(params[:state])\n \n # [Page Tab] return to the page tab\n if decoded_state['page_tab_id']\n\t\t\t graph = Koala::Facebook::API.new\n\t\t\t page_tab = graph.get_object(\"#{decoded_state['page_tab_id']}\")\n\t\t\t if page_tab[\"link\"]\n link = true\n\t\t\t\t encoded_page_state = URI.encode(ActiveSupport::JSON.encode(\n {:individual_user_id => session[:individual_user_id], \n :secret => session[:access_token]\n }))\n end\n end\n end\n \n # handle the redirect\n if state && link\n redirect_to(page_tab[\"link\"] + \n \"?sk=app_#{APP_ID}&app_data=#{encoded_page_state}\")\n else\n redirect_to(create_fb_url_with_creds(session[:individual_user_id],\n session[:access_token]))\n end\n return\n end",
"def facebook\n handle_auth \"facebook\"\n end",
"def proc_facebook_login\n \n puts \"proc_facebook_login\"\n \n puts request.env['rack.auth'].inspect\n \n \n # If user is already logged in, grab session variables\n if session[:user_name] && !session[:user_name].empty?\n @real_name = session[:real_name] \n @user_name = session[:user_name]\n @user_image = session[:user_image] \n else\n # If user is not logged in, grab authentication varaibles\n @real_name = request.env['rack.auth']['user_info']['name']\n @user_name = request.env['rack.auth']['user_info']['name']\n #@user_image = request.env['rack.auth']['user_info']['image']\n @user_image = \"\"\n \n session[:user_name] = @user_name\n session[:real_name] = @real_name\n session[:user_image] = @user_image \n end\n \n @exists = false\n @user_id = -1\n \n #puts \"Checking if user already exists in database...\"\n \n # Check if user already exists in database\n User.all.each do |user|\n if user[:twitter] == @user_name\n @exists = true\n @user_id = user.id\n session[:user_id] = @user_id\n break;\n end\n end\n \n # User does not exist in database. Add new user\n if !@exists\n new_user = User.new( :twitter => @user_name, :name => @real_name )\n new_user.save\n \n @user_id = new_user.id\n session[:user_id] = @user_id\n end\n \n # Redirect to the user home page\n redirect_to :action => \"home\"\n end",
"def register_user_to_fb\n if AppConfig.register_users_to_facebook\n begin # DON'T LET FACEBOOK FUCK UP NEW USERS\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n rescue Exception => e\n Rails.logger.warn \"Facebook barfed in User.register_user_to_fb: #{e.message}\"\n end\n end\n true\n end",
"def link_fb_to_user\n\t\trender :json=>{:success=>false, :msg=>'User not logged in.'} and return if @user.nil?\n\n\t\taccess_token = params[:access_token]\n\t\t\n\t\t#url = 'https://graph.facebook.com/me?access_token='+access_token\n\t\tbegin\n\t\t\tfb_user = FbGraph::User.fetch('me', :access_token=>access_token)\n\t\t\tfb_id = fb_user.identifier\n\t\t\temail = fb_user.email.strip.downcase\n\t\t\t\n\t\t\t#Check if user exists by email\n\t\t\tuser = User.find_by_email(email)\n\t\t\trender :json=>{:success=>false, :msg=>'An account already exists under your Facebook email.'} and return if (!user.nil? && user.id!=@user.id)\n\t\t\t\n\t\t\t#Check if user exists by Facebook ID\n\t\t\tuser = User.find_by_fb_id(fb_id)\n\t\t\trender :json=>{:success=>false, :msg=>'An account already exists under this Facebook account.'} and return if (!user.nil? && user.id!=@user.id)\n\t\t\t\n\t\t\t@user.fb_id = fb_id\n\t\t\t@user.fb_access_token = access_token\n\t\t\t\n\t\t\t@user.save\n\t\t\tsession['user'] = @user\n\t\t\t\n\t\t\trender :json=>{:success=>true, :msg=>'success'} and return\n\t\t\t\n\t\trescue\n\t\t\trender :json=>{:success=>false, :msg=>'There was an error. Refresh the page and try again.'} and return\n\t\tend\n\tend",
"def facebook\n handle_oauth\n end",
"def facebookcheck\n auth=request.env[\"omniauth.auth\"]\n session[:auth] = auth\n if (session[:check] == 1)\n redirect_to '/create/manager'\n elsif (session[:check] == 2)\n redirect_to '/create/tenant'\n else\n #differentiates the redirection for the log in of a tenant or manager\n if Manager.where(:provider => auth[\"provider\"], :uid => auth[\"uid\"]).exists?\n user=Manager.find_by(:provider => auth[\"provider\"], :uid => auth[\"uid\"])\n session[:user_id] = user.id\n redirect_to '/managers/show'\n elsif Tenant.where(:provider => auth[\"provider\"], :uid => auth[\"uid\"]).exists?\n user = Tenant.find_by(:provider => auth[\"provider\"], :uid => auth[\"uid\"]) \n session[:user_id] = user.id\n redirect_to '/tenants/show'\n #redirects incorrect sign ins\n else\n flash[:notice] = 'Incorrect login information.'\n redirect_to '/signin'\n end\n end\n end",
"def fbauthorize\n redirect_to fb_auth_login_url.to_s\n end",
"def test04_fb_login_existing_approved_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($facebook_home)\n\t\tfb_login\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.click\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T4: FAILED! Unable to login via Facebook.\"\n\t\tend\n\tend",
"def fill_fb_credentials\n\n fill_in FB_EMAIL_OR_ID_FIELD,with:FB_USER_ID\n fill_in FB_PASSWORD_FIELD,with:FB_USER_PASSWORD\n\nend",
"def new_facebook_signup\n \n @fb_data = fetch_facebook_params\n\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n if @user.blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token])\n \n @user.addresses.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n\n else\n @user.update_attributes(facebook_token: @fb_data[:fb_token]) if @user.facebook_token != @fb_data[:fb_token] #update the token if @user_founds token is not same as the @fb_token\n sign_in(:spree_user, @user)\n redirect_to main_app.profile_users_path\n end\n\n end",
"def register\n \n # Create a new user if necessary\n @current_user = User.find_or_initialize_by_facebook_id(params[:facebook_id])\n @current_user.facebook_access_token = params[:facebook_access_token]\n @current_user.first_name = params[:facebook_first_name]\n @current_user.last_name = params[:facebook_last_name]\n @current_user.full_name = params[:facebook_name]\n @current_user.save\n \n # Generate a random token for this user if this is the first time and setting create_at\n if @current_user.access_token.nil?\n @current_user.update_attribute('access_token', SecureRandom.hex(64))\n @current_user.set_joined_at\n end\n \n # Adding everyone to party pod where pod_id=1\n @current_user.add_to_pod(1)\n \n # Fetch friends for current user\n # find_friends_for_facebook_id(@current_user.facebook_id, nil)\n \n # The response only local access_token \n session_response_hash = {:access_token => @current_user.access_token}\n \n respond_to do |format|\n format.xml { render :xml => session_response_hash.to_xml }\n format.json { render :json => session_response_hash.to_json }\n end\n end",
"def det_facebook_login_method\n @status, @msg, @data = UserValidator.det_facebook_login_method(params)\n end",
"def facebook\n callback\n end",
"def create\n\n params[:user].reject! {|k,v| !['name','email','password','facebook_uid'].include?k }\n @user = User.new(params[:user])\n if @user.facebook_uid and current_facebook_user and current_facebook_client\n if current_facebook_user.id == @user.facebook_uid\n @user.facebook_session_key = current_facebook_client.access_token\n @user.password = \"fb-#{@user.facebook_uid}-\"+Time.now().to_s if @user.password.empty?\n end\n else\n if @user.password != params[:password_verify] then\n @user.errors.add(:password, \"Password fields don't match\")\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render json: @user }\n end\n return\n end\n end\n \n respond_to do |format|\n if @user.save\n UserSession.create(@user, true)\n format.html { redirect_to(@user, :notice => 'User was successfully created.') }\n format.json { render json: @user }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @user }\n end\n end\n end",
"def create_from_oauth\n if stored_anonymous_user?\n user, from_registration = update_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n else\n user, from_registration = create_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n end\n\n if user.errors.any?\n redirect_to_registration_page(user)\n else\n change_global_user_id(user.id)\n sign_in(user)\n fandom_play_login(user)\n \n if from_registration\n log_data = { 'form_data' => env[\"omniauth.auth\"], 'user_id' => current_user.id }\n log_synced(\"registration from oauth\", adjust_user_and_log_data_with_utm(user, log_data))\n\n set_account_up()\n cookies[:from_registration] = true \n end\n\n if $site.force_facebook_tab && !request_is_from_mobile_device?(request)\n redirect_to request.site.force_facebook_tab\n else\n redirect_after_oauth_successful_login()\n end\n end\n end",
"def facebook\n\n end",
"def show\n begin\n auth = Facebook.auth.from_cookie(cookies)\n fb = Facebook.identify(auth.user)\n\n # verify fb account and set session id\n authenticate fb\n\n # valid facebook account found, pull details\n profile = FbGraph::User.me(fb.access_token).fetch\n fb.first_name = profile.first_name\n fb.last_name = profile.last_name\n fb.save\n\n # redirect_to dashboard_url\n redirect_to :controller => :dashboard, :action => :index\n\n rescue Exception => e\n logger.error \"Error: \" + e.message\n # logger.error e.backtrace.inspect\n flash[:notice] = \"An error has occurred while communicating with Facebook\"\n redirect_to root_url\n end\n end",
"def before_create_user\n logger.debug(\"on before creare user\")\n #Generate a unique key\n if facebook_user?\n self.active = 1 \n else\n activation_key_string = self.salt+self.email+self.hashed_password\n self.activation_key =Digest::SHA1.hexdigest(activation_key_string)\n self.active = 0\n end\n self.admin = 0 \n self.handle=generate_unique_handle\n \n end",
"def show\n auth = Facebook.auth.from_cookie(cookies)\n authenticate Facebook.identify(auth.user)\n redirect_to dashboard_url\n end",
"def update\n # TODO: wrap into Facebook class?\n fb_response = Facebook.new(params[:facebook_access_token]).get(\"/me\")\n \n # TODO: handle errors, security\n\n if fb_response.code != 200\n render :nothing => true, :status => 401\n else\n @user = User.find_by_facebook_id(fb_response['id'])\n\n if @user\n # existing user logging-in\n @user.update_attribute(:facebook_token, params[:facebook_access_token])\n render :nothing => true, :status => 200\n else\n # shinny new user logging-in\n @user = User.create_from_facebook_response(params[:facebook_access_token], fb_response)\n if @user.save\n render :nothing => true, :status => 201\n else\n render :nothing => true, :status => 500\n raise \"could not save new user\"\n end\n end\n end\n end",
"def transfer_to_facebook_account(facebook_user_id)\n\n # current account (old) -> facebook account (new)\n # current is destroyed\n # current account must be standard account\n\n old_user = self\n new_user = User.find(facebook_user_id)\n\n # the current user (old_user) should be a standard account (log in with email/password)\n raise \"Current user (the one which will be destroyed) is not a standard account!\" if !old_user.standard_account?\n\n # the new user should be a facebook-authenticated account\n raise \"New user (the one to be merged to and retained) is not a facebook account!\" if !new_user.facebook_account?\n\n transfer_account :old => old_user, :new => new_user\n\n end",
"def show\n auth = Authentication.auth.from_cookie(cookies)\n authenticate Authentication.identify(auth.user)\n redirect_to Facebook.config[:app_url]\n end",
"def ensure_authenticated\n if current_facebook_user.nil? && params[:Caller].blank?\n redirect_to url_for(:controller => \"login\")\n else\n if params[:Caller]\n phone = params[:Caller].match(/(\\d){10}$/)[0]\n @user = Phone.find_by_number(phone).try(:user)\n unless @user\n redirect_to url_for(:controller => \"login\", :action => \"not_found\", :format => :xml)\n return\n end\n offline_client = Mogli::Client.new(@user.facebook_access_token, nil)\n fb_user = Mogli::User.find(@user.facebook_id, offline_client) # reusing current_facebook_user breaks use in else, somehow\n else\n @user = User.find_or_create_by_facebook_id(current_facebook_user.id)\n #not the best place, but ...\n set_access_token\n current_facebook_user.fetch\n end\n @feed = FbFeed.new(@user)\n logger.debug(\"twilio, #{ @feed }\")\n logger.debug(\"url = https://graph.facebook.com/#{ @user.facebook_id }/home?access_token=#{ @user.facebook_access_token }\")\n end\n end",
"def create_fb\n if current_facebook_user\n current_facebook_user.fetch\n if logged_in_member\n logged_in_member.update_attribute(:fb_user_id, current_facebook_user.id)\n redirect_to logged_in_member\n else\n @member = Member.find_or_initialize_with_facebook(current_facebook_user)\n conference_delegate = ConferenceDelegate.find_by_signature(params[:signature]) if !params[:signature].blank?\n if @member.new_record?\n @member.conference_delegate = conference_delegate\n @member.auth_service = 'Facebook'\n render :template => \"sessions/register_email\"\n else\n if conference_delegate && conference_delegate.member.nil? && @member.conference_delegate.nil?\n conference_delegate.update_attribute(:member, @member)\n end\n login_member!(@member)\n end\n end\n else\n redirect_to new_session_path\n end\n end",
"def register_user_to_fb\n\t #users = {:email => email, :account_id => id}\n\t #Facebooker::User.register([users])\n\t #self.email_hash = Facebooker::User.hash_email(email)\n\t #save(false)\n\tend",
"def create\n email = params[:email]\n password = params[:password]\n fb_token = params[:fbtoken]\n if request.format != :json\n render :status => 406, :json => {:message => 'The request must be json'}\n return\n end\n\n if (email.nil? or password.nil?) && fb_token.nil?\n render :status => 400,\n :json => {:message => 'The request must contain the user email and password or FB token.'}\n return\n end\n\n if fb_token\n #check token\n begin\n facebook_graph = ::Koala::Facebook::API.new('595428443887130|BMCDixQJlECImLZsnnxGBO2jtoI')\n @token_info = facebook_graph.debug_token(fb_token)\n logger.info @token_info.inspect\n @user = User.find_by(fb_id: @token_info['data']['user_id'])\n rescue => e\n logger.error e.message\n @user = nil\n end\n else\n @user = User.find_by(email: email.downcase)\n end\n\n if @user.nil?\n logger.info(\"User #{email || fb_token} failed signin, user cannot be found.\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n return\n end\n\n # http://rdoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable\n #@user.generate_authentication_token\n\n valid = (!fb_token && @user.valid_password?(password)) || (fb_token && @token_info['data']['app_id'] == '595428443887130')\n\n if valid\n @user.ensure_authentication_token\n logger.info 'Token: ' + @user.authentication_token.to_s\n @user.save_device_token(params[:device_token])\n render :status => 200, :json => {:token => @user.authentication_token, :email => @user.email, :premium => !@user.role?(:free)}\n else\n logger.info(\"User #{email} failed signin, password \\\"#{password}\\\" is invalid\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n end\n end",
"def facebook\n end",
"def create\n client = FacebookAccount.auth(callback_prive_options_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token!\n user = FbGraph::User.me(access_token).fetch\n FacebookAccount.identify(user, @salon.id)\n redirect_to prive_options_facebooks_path, :notice => \"La page facebook est liée au compte\"\n end",
"def callback\n auth = request.env['omniauth.auth']\n\n session[:facebook_token] = auth[:credentials][:token]\n\n refresh_facebook\n\n redirect_to '/#services'\n end",
"def authenticate_user!\n redirect_to login_path(:facebook) unless session[:user_id]\n end",
"def developer\n raise 'Invalid Authentication' unless ENV['FAKE_AUTH_ENABLED'] == 'true'\n @user = User.from_omniauth(request.env['omniauth.auth'])\n @user.save\n sign_in_and_redirect @user, event: :authentication\n flash[:notice] = \"Welcome #{@user.email}!\"\n end",
"def link_fb_connect(fb_user)\n\t unless fb_user.id.nil?\n\t #check for existing account\n\t existing_fb_user = RmUser.find_by_fb_usid(fb_user.id)\n\t #unlink the existing account\n\t unless existing_fb_user.nil?\n\t #existing_fb_user.fb_usid = nil\n\t #existing_fb_user.save(false)\n\t end\n\t #link the new one\n\t self.fb_usid = fb_user.id\n\t self.first_name = fb_user.first_name\n\t self.last_name = fb_user.last_name\n\t #self.name = \n\t save(false)\n\t end\n\tend",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n # UPDATE:\n # allow multiple accounts to use the same facebook id I guess - \n # makes debugging a lot easier too\n existing_fb_user = User.find_by_facebook_uid(fb_user_id)\n \n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.facebook_id = nil\n existing_fb_user.save(false)\n end\n #link the new one\n self.facebook_id = fb_user_id\n save(false)\n end\n end",
"def oauth_signup\n @user = User.new(\n nickname: params[:nickname],\n sex: params[:sex],\n phone: params[:phone],\n birthday: params[:birthday],\n province: params[:province],\n city: params[:city],\n area: params[:area] )\n @user.created_by_oauth = 'mobile'\n @user.authentications.build(\n uid: params[:oauth_uid],\n provider: params[:provider],\n access_token: params[:access_token])\n if @user.save\n @user.confirm!\n render :login\n else\n render json: {\n success: false,\n message: @user.errors.messages\n }\n end\n end",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n existing_fb_user = User.find_by_fb_user_id(fb_user_id)\n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.fb_user_id = nil\n existing_fb_user.save(false)\n end\n #link the new one\n self.fb_user_id = fb_user_id\n save(false)\n end\n end",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n existing_fb_user = User.find_by_fb_user_id(fb_user_id)\n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.fb_user_id = nil\n existing_fb_user.save(false)\n end\n #link the new one\n self.fb_user_id = fb_user_id\n save(false)\n end\n end",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n existing_fb_user = User.find_by_fb_user_id(fb_user_id)\n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.fb_user_id = nil\n existing_fb_user.save(false)\n end\n #link the new one\n self.fb_user_id = fb_user_id\n save(false)\n end\n end",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n existing_fb_user = User.find_by_fb_user_id(fb_user_id)\n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.fb_user_id = nil\n existing_fb_user.save(false)\n end\n #link the new one\n self.fb_user_id = fb_user_id\n save(false)\n end\n end",
"def connect\n raise ArgumentError unless (params[:fname] == '_opener')\n raise ArgumentError unless connect = ActiveSupport::JSON.decode(params[:session])\n\n @user = User.find_by_facebook_uid(connect['uid'])\n\n if @user.nil?\n # create a new user for the Facebook User if not present\n @user = User.new\n @user.facebook_uid = connect['uid']\n\n # XXX this is crap: login, country and email should be fetched from the facebook. Why?\n # because: login clashes could occur (if an user names itself fb_123456), the \"unknown\"\n # country is BAD design, because it's a corner case to cope with in views, and the fake\n # email is USELESS to send mewsic e-mail notifications to the user.\n #\n @user.login = \"fb_#{@user.facebook_uid}\" # XXX\n @user.country = \"unknown\" # XXX\n @user.email = \"#{@user.facebook_uid}@users.facebook.com\" # XXX\n\n @user.password = @user.password_confirmation = rand(2**32).to_s\n @user.save!\n end\n\n session[:fb_connect] = true\n self.current_user = @user\n\n # render the cross-domain communication channel\n render :layout => false\n\n rescue ActiveRecord::ActiveRecordError\n debugger\n head :forbidden\n\n rescue ArgumentError\n head :bad_request\n end",
"def facebook\n oauth_info = OauthToken.get_oauth_info('facebook')\n session[:redirect_after_oauth] = params[:redirect_to] ? params[:redirect_to] : nil\n redirect_to \"https://graph.facebook.com/oauth/authorize?client_id=#{oauth_info['consumer_key']}\"+\n \"&redirect_uri=#{oauth_info['callback']}\"+\n \"&scope=read_stream,publish_stream,publish_actions,offline_access,user_likes,user_status,\"+\n \"user_birthday,user_relationships,user_relationship_details,\"+\n \"email,user_checkins,sms,user_online_presence\"+\n \"&display=touch\"\n end",
"def new_with_redirect;\n\t\t@user=User.new;\n\t\treturn redirect_to auth_path(:facebook) if params[:with]==\"facebook\"\n\t\treturn redirect_to auth_path(:linkedin) if params[:with]==\"linkedin\"\n\t\tif !auth_hash.blank?\n\t\t\tif @user.facebook_info(auth_hash)=='mail missing'\n\t\t\t\tflash[:error]='Sign up failed, we need your email to sign you up'\n\t\t\t\tredirect_to root_path\n\t\t\tend\n\t\tend\n\tend",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n existing_fb_user = metaclass.send(\"find_by_#{fb_user_name}\", fb_user_id)\n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.send(\"#{fb_user_name}_id=\", nil)\n existing_fb_user.save(false)\n end\n #link the new one\n self.send(\"#{fb_user_name}_id=\", fb_user_id)\n save(false)\n end\n end",
"def set_facebook_connect_session\n load_facebook_connect\n #set_facebook_session\n create_facebook_session\n Rails.logger.debug \"*** create_facebook_session returned with #{@facebook_session.inspect}\"\n \n # If user is logged in to facebook but not logged in using FB Connect,\n # destroy session info\n if @facebook_session && @facebook_session.user && current_user && !current_user.facebook_id.blank? &&\n (current_user.facebook_id.to_s != @facebook_session.user.id.to_s)\n Rails.logger.debug \"current user facebook id #{current_user.facebook_id} != facebook session id #{@facebook_session.user.id}\"\n Rails.logger.debug \"Facebook user id conflict - Clearing facebook session\"\n flash[:error] = \"This facebook account is in use by another Eternos account.\"\n @facebook_session = nil\n end\n end",
"def callback_facebook\n token = env[\"omniauth.auth\"][:credentials][:token]\n first_name = env[\"omniauth.auth\"][:info][:first_name]\n email = env[\"omniauth.auth\"][:info][:email]\n\n\n # Create new Subscriber record.\n deal = Deal.find(request.env['HTTP_REFERER'].split('?').first.split('/').last)\n @subscriber = Subscriber.new(first_name: first_name, email: email, deal_id: deal.id)\n @subscriber.save\n\n # Post deal's info to user timeline.\n user = FbGraph::User.me(token)\n\n if Rails.env.development?\n image_url = deal.image.present?? \"http://welovemerthyr.dev#{deal.image_url(:thumb)}\" : ''\n elsif Rails.env.production?\n image_url = deal.image.present?? deal.image_url(:thumb) : ''\n end\n\n user.feed!(\n message: \"Voucher from WeLoveMerthyr\",\n picture: image_url,\n link: public_voucher_url(deal),\n name: deal.title,\n description: deal.description.gsub('<p>', '').gsub('</p>', '')\n )\n\n redirect_to request.env['HTTP_REFERER'].split('?').first << \"?step=2\"\n end",
"def handle_omniauth_callback(auth)\n # Try to find authentication first\n authentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])\n provider = auth['provider'] || 'Unknown'\n\n ## data of facebook\n # info=#<OmniAuth::AuthHash::InfoHash email=\"phanhoanglong2610@gmail.com\"\n # first_name=\"Long\" image=\"http://graph.facebook.com/100000709457324/picture?type=square\"\n # last_name=\"Phan-Hoàng\" location=\"Ho Chi Minh City, Vietnam\" name=\"Long Phan-Hoàng\"\n # nickname=\"phanhoanglong2610\"\n # urls=#<Hashie::Mash Facebook=\"http://www.facebook.com/phanhoanglong2610\">\n # verified=true> provider=\"facebook\" uid=\"100000709457324\"\n\n if authentication\n\n # sign in and direct to previous page\n sign_in_and_redirect authentication.user, :event => :authentication\n set_flash_message(:notice, :success, :kind => auth[\"facebook\"]) if is_navigational_format?\n\n else\n # Authentication not found, thus a new user.\n @user = User.new\n\n # temp for username social accounts such as Twitter\n\n #prefill with info from provider website\n @user.apply_omniauth(auth)\n\n @info = {\n \t:first_name => @user.first_name,\n \t:last_name => @user.last_name,\n \t:email => @user.email\n }\n\n session[\"devise.#{auth[\"provider\"]}_data\"] = auth.except(\"extra\")\n\n render :template => \"devise/registrations/new\"\n end\n\tend",
"def make_user\n @user = User.new(session_token: params[:session_token])\n graph = Koala::Facebook::API.new(@user.session_token)\n id = graph.get_object(\"me\")[\"id\"]\n if id != params[:facebook_id]\n render json: [\"Invalid session token\"], status: 401\n return\n end\n @user.fill_user_data(graph)\n if @user.save\n # @user.add_friends(graph)\n render \"api/users/show\"\n else\n render json: @user.errors.full_messages, status: 422\n end\n end",
"def create\n auth = request.env[\"omniauth.auth\"] \n user = User.find_by_fb_id(auth[\"uid\"]) || User.create_with_omniauth(auth) \n #for those update from feeds\n if user.access_token.empty?\n user.access_token = auth[\"credentials\"][\"token\"]\n user.save\n end\n redirect_to FB_APP_URL \n end",
"def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n User.update(user.id, :fb_nickname => auth[\"info\"][\"nickname\"])\n session[:user_id] = user.id\n redirect_to root_url\n end",
"def import_user\n fb_uid = facebook_params[:user]\n @user = User.find_or_create_by_fb_uid(fb_uid)\n @user.session_key = facebook_params[:session_key]\n # if we are here, the user is using our app, so they are an app user\n if @user.status == Status::Invited\n @user.status = Status::AddedApplication\n end\n return true\n end",
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n existing_fb_user = User.find_by_fb_user_id(fb_user_id)\n #unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.fb_user_id = nil\n existing_fb_user.save(false)\n end\n #link the new one\n self.fb_user_id = fb_user_id\n save(false)\n end\n end",
"def new\n \n fb_auth = FbGraph::Auth.new('155275974530339', '309d340d359061c890906926e8139e4a')\n fb_auth.client # => Rack::OAuth2::Client\n \n client = fb_auth.client\n client.redirect_uri = \"http://localhost:3000/config_keys\"\n\n # redirect user to facebook\n redirect_to client.authorization_uri(\n :scope => [:email, :read_stream, :offline_access]\n )\n\n # in callback\n client.authorization_code = params[:code]\n access_token = client.access_token! # => Rack::OAuth2::AccessToken\n FbGraph::User.me(access_token).fetch # => FbGraph::User\n \n end",
"def fetch_details_from_facebook\n\t\t# graph = Koala::Facebook::API.new(self.token)\n\t\t# facebook_data = graph.get_object(\"me\")\n\t\t# self.username = facebook_data['username']\n\t\t# self.save\n\t\t# self.user.username = facebook_data['username'] if self.user.username.blank?\n\t\t# self.user.image = \"http://graph.facebook.com/\" + self.username + \"/picture?type=large\" if self.user.image.blank?\n\t\t# self.user.location = facebook_data['location'] if self.user.location.blank?\n\t\t# self.user.save\n\t\tself.user.has_facebook = true\n\t\tself.user.save\n\tend",
"def facebook\n @fb_user ||= FbGraph::User.me(self.authentications.find_by_provider('facebook').token)\n @fb_user.fetch\n end",
"def facebook\n @fb_user ||= FbGraph::User.me( self.authentications.find_by_provider('facebook').token)\n end",
"def create\n auth = request.env[\"omniauth.auth\"]\n user_info = auth[\"info\"] ? auth[\"info\"] : auth[\"user_info\"]\n authentication = Authorization.where(:provider => auth['provider'], :uid => auth['uid']).first\n authentication = Authorization.new(:provider => auth['provider'], :uid => auth['uid']) if !authentication\n session[:fb_token] = auth['credentials']['token'] if auth['credentials']['token'] != nil\n # if the user exists, but does not have a link with the social service\n if !authentication.user && current_user\n authentication.user = current_user\n authentication.save\n end\n # twitter only (gets no email)\n if !authentication.user && !user_info[\"email\"]\n flash[:notice] = \"No user linked to this account. Please sign in or create a new account\"\n redirect_to '/users/sign_up/'\n # if user doesnt exists, register user\n elsif !authentication.user\n user = User.where(email: user_info['email']).first\n if user\n authentication.user = user\n else\n new_user = User.new(email: user_info['email'], username: user_info['name'], first_name: user_info['first_name'], last_name: user_info['last_name'], role: \"registered\")\n new_user.save\n authentication.user = new_user\n end\n authentication.save\n end\n # if user exists, sign in. Gives a Mongoid glitch of not signing in after registration. So double sign in\n if authentication.user\n if !current_user\n sign_in authentication.user\n sign_out authentication.user\n sign_in authentication.user\n # raise \"user signed in? #{user_signed_in?.to_s}\".inspect\n flash[:notice] = \"Authorization successful.\"\n redirect_to root_path\n else\n flash[:notice] = \"Linked successfully.\"\n redirect_to '/users/'+current_user.id\n end\n end\n end",
"def prepare_to_publish\n manager = OauthManager.new(@vehicle)\n @oauth = manager.oauth\n redirect_to manager.url\n\n rescue Exception => e\n flash[:error] = \"No se pudo autenticar con Facebook. #{e}\"\n redirect_to vehicles_path\n end"
] |
[
"0.679115",
"0.6735726",
"0.6609625",
"0.6596209",
"0.6591692",
"0.6583103",
"0.65577483",
"0.6554772",
"0.65363556",
"0.65348667",
"0.65310067",
"0.6510138",
"0.6482514",
"0.6436525",
"0.6419062",
"0.64186287",
"0.64052296",
"0.63961077",
"0.6390426",
"0.6379573",
"0.6371273",
"0.6365029",
"0.6364338",
"0.6359877",
"0.6351915",
"0.633377",
"0.63163185",
"0.63145554",
"0.6270712",
"0.62663597",
"0.62606275",
"0.62482554",
"0.62120235",
"0.6199014",
"0.61916804",
"0.61867166",
"0.6183606",
"0.61813617",
"0.61727977",
"0.616917",
"0.6157477",
"0.6145263",
"0.61277056",
"0.6119692",
"0.61152256",
"0.6108152",
"0.61013025",
"0.6082296",
"0.6075308",
"0.60662866",
"0.60269976",
"0.6004164",
"0.6000592",
"0.598686",
"0.59737545",
"0.5967042",
"0.596538",
"0.59561604",
"0.59500045",
"0.5946388",
"0.59163344",
"0.5914315",
"0.58979565",
"0.587862",
"0.5878104",
"0.5873812",
"0.58718157",
"0.58669984",
"0.58585614",
"0.58527666",
"0.5837282",
"0.5835591",
"0.58354276",
"0.5806755",
"0.58041996",
"0.58039355",
"0.5798568",
"0.5793529",
"0.57933384",
"0.57933384",
"0.57933384",
"0.57933384",
"0.57847595",
"0.5780286",
"0.57591",
"0.57569915",
"0.5755826",
"0.5749994",
"0.5739355",
"0.57378846",
"0.57328874",
"0.57278603",
"0.57156026",
"0.57072026",
"0.5706927",
"0.5694238",
"0.5688307",
"0.56629074",
"0.5658443",
"0.56464535"
] |
0.63679475
|
21
|
Returns the list of partition types supported by the Device
|
def partition_types_ext
ptr1 = MemoryPointer::new( :size_t, 1)
error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, 0, nil, ptr1)
error_check(error)
ptr2 = MemoryPointer::new( ptr1.read_size_t )
error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, ptr1.read_size_t, ptr2, nil)
error_check(error)
arr = ptr2.get_array_of_cl_device_partition_property_ext(0, ptr1.read_size_t/ OpenCL.find_type(:cl_device_partition_property_ext).size)
arr.reject! { |e| e == 0 }
return arr.collect { |e| PartitionEXT::new(e.to_i) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list_partitions_with_size_and_type # by nelsongs. => list: partition size type\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\") print $1\":\"$5\":\"$6;else print $1\":\"$4\":\"$5}' | sed s/+//g`.split\nend",
"def list_partitions #by nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{print $1}'`.chomp.split\nend",
"def get_storage_types\n JSON.parse(RestClient.get(\"https://#{region.sub(/-\\d$/, '')}.power-iaas.cloud.ibm.com/broker/v1/storage-types\", headers))[region]\n end",
"def available_partitions\n partitions.select(&:available?)\n end",
"def GetPartitionLst(tg, device)\n tg = deep_copy(tg)\n ret = []\n tmp = GetDiskPartitionTg(device, tg)\n Builtins.y2milestone(\"GetPartitionLst tmp:%1\", tmp)\n Builtins.foreach(tmp) do |m|\n disk = Ops.get_string(m, \"disk\", \"\")\n if Builtins.search(device, \"/dev/evms\") == 0 &&\n !Builtins.haskey(tg, disk)\n disk = \"/dev/evms\"\n end\n Builtins.y2debug(\"GetPartitionLst device=%1 disk=%2\", device, disk)\n part = Builtins.filter(Ops.get_list(tg, [disk, \"partitions\"], [])) do |p|\n Ops.get_string(p, \"device\", \"\") == device\n end\n part = Builtins.filter(part) { |p| !Ops.get_boolean(p, \"delete\", false) }\n if Builtins.size(part) == 0 && Ops.is_integer?(Ops.get(m, \"nr\", 0))\n part = Builtins.filter(Ops.get_list(tg, [disk, \"partitions\"], [])) do |p|\n Ops.get_integer(p, \"nr\", -1) == Ops.get_integer(m, \"nr\", 0)\n end\n part = Builtins.filter(part) do |p|\n !Ops.get_boolean(p, \"delete\", false)\n end\n end\n if Builtins.size(part) == 0\n part = Builtins.filter(Ops.get_list(tg, [disk, \"partitions\"], [])) do |p|\n Ops.get_string(p, \"name\", \"\") == Ops.get_string(m, \"nr\", \"\")\n end\n part = Builtins.filter(part) do |p|\n !Ops.get_boolean(p, \"delete\", false)\n end\n end\n pa = Ops.get(part, 0, {})\n if Builtins.size(pa) == 0 &&\n Builtins.search(device, \"/dev/mapper/\") == 0\n part = Builtins.filter(\n Ops.get_list(tg, [\"/dev/mapper\", \"partitions\"], [])\n ) { |p| Ops.get_string(p, \"device\", \"\") == device }\n pa = Ops.get(part, 0, {})\n end\n if Builtins.size(pa) == 0 &&\n Builtins.search(device, \"/dev/mapper/\") == 0\n part = Builtins.filter(\n Ops.get_list(tg, [\"/dev/loop\", \"partitions\"], [])\n ) { |p| Ops.get_string(p, \"device\", \"\") == device }\n pa = Ops.get(part, 0, {})\n end\n ret = Builtins.add(ret, pa) if Ops.greater_than(Builtins.size(pa), 0)\n end\n Builtins.y2debug(\"GetPartitionLst ret=%1\", ret)\n deep_copy(ret)\n end",
"def list_swap_partitions_with_type_and_size # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $1\":\"$5\":\"$6;else {if ($5==\"82\") print $1\":\"$4\":\"$5}}' | sed s/+//g`.chomp.split\nend",
"def list_nix_partitions_with_size_and_type # nelsongs\n\t`fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && ($6==\"83\" || $6==\"82\")) print $1\":\"$5\":\"$6;else {if ($5==\"83\" || $5==\"82\") print $1\":\"$4\":\"$5}}' | sed s/+//g`.split\nend",
"def platform_types\n get(\"platform-types\")[\"types\"]\n end",
"def partition_type\n raise Error, \"Unable to determine partition type, multiple different partitioning methods called\" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1\n\n if @from || @to\n raise Error, \"must call both from and to when creating a partition of a table if calling either\" unless @from && @to\n :range\n elsif @in\n :list\n elsif @modulus || @remainder\n raise Error, \"must call both modulus and remainder when creating a partition of a table if calling either\" unless @modulus && @remainder\n :hash\n elsif @default\n :default\n else\n raise Error, \"unable to determine partition type, no partitioning methods called\"\n end\n end",
"def make_partition_list(withall, flavor)\n part_list = []\n Builtins.foreach(RootPart.rootPartitions) do |partition, i|\n # see https://bugzilla.novell.com/attachment.cgi?id=96783&action=view\n\n # see bugzilla #288201\n # architecture needs to be valid when updating, not booting\n arch_is_valid = flavor == :boot ?\n true :\n Ops.get_boolean(i, :arch_valid, false)\n if withall || Ops.get_boolean(i, :valid, false) && arch_is_valid\n # `ext2, `jfs, ...\n part_fs = Ops.get_symbol(i, :fs)\n part_fs_name = Builtins.tostring(part_fs)\n if part_fs_name != nil &&\n Builtins.regexpmatch(part_fs_name, \"^`(.*)$\")\n part_fs_name = Builtins.regexpsub(part_fs_name, \"^`(.*)$\", \"\\\\1\")\n end\n\n system = Ops.get_string(i, :name, \"error\")\n # unknown system\n if system == \"unknown\"\n if part_fs != nil\n if CanBeLinuxRootFS(part_fs)\n # Table item (unknown system)\n system = _(\"Unknown Linux\")\n else\n # Table item (unknown system)\n system = _(\"Unknown or Non-Linux\")\n end\n else\n # Table item (unknown system [neither openSUSE 11.1 nor SLES 14 nor ...])\n system = _(\"Unknown\") if system == \"unknown\"\n end\n end\n\n arch = Ops.get_string(i, :arch, \"error\")\n # Table item (unknown architecture)\n arch = _(\"Unknown\") if arch == \"unknown\"\n\n # fist, use the name of file system (with short name for Linux)\n # then the file system short name\n # then \"Unknown\"\n fs = \"\"\n\n # is a linux fs, can be a root fs, has a fs name\n if part_fs != nil && Ops.get(i, :fstype) != nil &&\n CanBeLinuxRootFS(part_fs) &&\n part_fs_name != nil\n fs = Builtins.sformat(\n _(\"%1 (%2)\"),\n Ops.get_string(i, :fstype, \"\"),\n part_fs_name\n )\n else\n fs = Ops.get_string(i, :fstype, Ops.get_string(i, :fs, \"\"))\n end\n # Table item (unknown file system)\n fs = _(\"Unknown\") if fs == \"\"\n\n label = Ops.get_string(i, :label, \"\")\n\n part_list = Builtins.add(\n part_list,\n Item(Id(partition), system, partition, arch, fs, label)\n )\n end\n end\n deep_copy(part_list)\n end",
"def get_pt_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/\\sPTTYPE=\\\"(.*?)\\\"/)\n match = '' if match.nil?\n\n Chef::Log.info(\"Partition type for device #{device}: #{match[1]}\")\n match[1]\nend",
"def ocs_storages_disk_only\n disks = []\n for o in ocs_storages\n if o.TYPE == 'disk'\n disks << o\n end\n end\n disks\n end",
"def GetPartitionList\n deep_copy(@partition_info)\n end",
"def partition_type_hex kname\n # Return Hex value of the partition type.Reliable compared to pure tex comparison.\n # Reference: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/ch-partitions-x86.html#tb-partitions-types-x86\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"udevadm\"\n params = \" info --query=property --name=#{kname}\"\n end\n udevadm = CommandsExecutor.new command, params\n udevadm.execute false, false # None blocking and not debug mode\n raise \"Command execution error: #{udevadm.stderr.read}\" if not udevadm.success?\n udevadm.result.each_line do |line|\n line.squish!\n key = 'ID_PART_ENTRY_TYPE'\n _key, value = line.split '='\n return value.hex if _key.eql? key\n end\n end",
"def allowed_types\n\t\t[Device]\n\tend",
"def applicable_device_types\n return @applicable_device_types\n end",
"def available_types\n # TODO pull this from DB or config\n [\n :kiosk,\n :ride,\n :store,\n :restaurant\n ]\n end",
"def disks\n self.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk)\n end",
"def IsPartitionable(entry)\n entry = deep_copy(entry)\n Ops.get_symbol(entry, \"type\", :CT_UNKNOWN) == :CT_DMRAID ||\n Ops.get_symbol(entry, \"type\", :CT_UNKNOWN) == :CT_DMMULTIPATH ||\n Ops.get_symbol(entry, \"type\", :CT_UNKNOWN) == :CT_MDPART ||\n IsRealDisk(entry)\n end",
"def platform_types\n @platform_types.to_hash\n end",
"def list_nix_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"83\") print $1;else {if ($5==\"83\") print $1}}'`.chomp.split\nend",
"def supports_list_partitions?\n postgresql_version >= 100_000\n end",
"def get_available_types()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('uiconf', 'getAvailableTypes', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def partitions\n topics.values.flat_map(&:partitions)\n end",
"def select_storage_devices(component)\n pci_devices = component.try(:pciDevices).try(:select) { |device| storage_device?(device) }\n addin_cards = component.try(:addinCards).try(:select) { |device| storage_device?(device) }\n\n devices = []\n devices.concat(pci_devices) if pci_devices.present?\n devices.concat(addin_cards) if addin_cards.present?\n devices\n end",
"def disk_specs(path)\n specs = []\n unit = 0\n if resource[:virtual_disks]\n resource[:virtual_disks].each do |vd|\n size = vd[\"size\"].to_i * 1024 * 1024\n specs << disk_spec(path, size, unit)\n unit += 1\n end\n else\n specs << disk_spec(path, resource[:disk_size], unit)\n end\n\n specs\n end",
"def bootloader_partitions\n raise RuntimeError, \"Not implemented in base class\"\n end",
"def serial_types\n types = []\n types << 'SX' if %w[b s].include?(record.leader[7])\n types.concat journal_types\n types.concat newspaper_types\n types.uniq!\n return types\n end",
"def get_partition_info\n # remove leading slash so it matches the packages.DU path\n remove_slash = true\n\n if !Stage.initial\n # read /proc/mounts as a list of maps\n # $[\"file\":\"/boot\", \"freq\":0, \"mntops\":\"rw\", \"passno\":0, \"spec\":\"/dev/sda1\", \"vfstype\":\"ext2\"]\n mounts = Convert.convert(\n SCR.Read(path(\".proc.mounts\")),\n :from => \"any\",\n :to => \"list <map <string, any>>\"\n )\n Builtins.y2milestone(\"mounts %1\", mounts)\n\n partitions = []\n Builtins.foreach(mounts) do |mpoint|\n name = Ops.get_string(mpoint, \"file\", \"\")\n if Builtins.substring(name, 0, 1) == \"/\" &&\n Builtins.substring(name, 0, 5) != \"/dev/\" && # filter out /dev/pts etc.\n Ops.get_string(mpoint, \"vfstype\", \"\") != \"rootfs\" # filter out duplicate \"/\" entry\n capacity = Pkg.TargetCapacity(name)\n if capacity != 0 # dont look at pseudo-devices (proc, shmfs, ...)\n used = Pkg.TargetUsed(name)\n partitions = Builtins.add(\n partitions,\n {\n \"name\" => name,\n \"free\" => Ops.subtract(capacity, used),\n \"used\" => used\n }\n )\n end\n end\n end\n Pkg.TargetInitDU(partitions)\n Builtins.y2milestone(\"get_partition_info: %1\", partitions)\n return deep_copy(partitions)\n end # !Stage::initial ()\n\n # remove the previous failures\n @failed_mounts = []\n\n # installation stage - Storage:: is definitely present\n # call Storage::GetTargetMap()\n targets = Convert.convert(\n WFM.call(\"wrapper_storage\", [\"GetTargetMap\"]),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n\n if targets == nil\n Builtins.y2error(\"Target map is nil, Storage:: is probably missing\")\n end\n\n if Mode.test\n targets = Convert.convert(\n SCR.Read(path(\".target.yast2\"), \"test_target_map.ycp\"),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n end\n\n target_partitions = []\n min_spare = 20 * 1024 * 1024 # minimum free space ( 20 MB )\n\n Builtins.foreach(targets) do |disk, diskinfo|\n part_info = Ops.get_list(diskinfo, \"partitions\", [])\n Builtins.foreach(part_info) do |part|\n Builtins.y2milestone(\"Adding partition: %1\", part)\n used_fs = Ops.get_symbol(part, \"used_fs\", :unknown)\n # ignore VFAT and NTFS partitions (bnc#)\n if used_fs == :vfat || used_fs == :ntfs\n Builtins.y2warning(\n \"Ignoring partition %1 with %2 filesystem\",\n Ops.get_string(part, \"device\", \"\"),\n used_fs\n )\n else\n free_size = 0\n\n if Ops.get(part, \"mount\") != nil &&\n Builtins.substring(Ops.get_string(part, \"mount\", \"\"), 0, 1) == \"/\"\n if Ops.get(part, \"create\") == true ||\n Ops.get(part, \"delete\") == false ||\n Ops.get(part, \"create\") == nil &&\n Ops.get(part, \"delete\") == nil\n Builtins.y2debug(\n \"get_partition_info: adding partition: %1\",\n part\n )\n\n # get free_size on partition in kBytes\n free_size = Ops.multiply(\n Ops.get_integer(part, \"size_k\", 0),\n 1024\n )\n free_size = Ops.subtract(free_size, min_spare)\n\n # free_size smaller than min_spare, fix negative value\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n\n used = 0\n if !(Ops.get_boolean(part, \"create\", false) ||\n Ops.get_boolean(part, \"format\", false))\n tmpdir = Convert.to_string(SCR.Read(path(\".target.tmpdir\")))\n tmpdir = Ops.add(tmpdir, \"/diskspace_mount\")\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"test -d %1 || mkdir -p %1\", tmpdir)\n )\n\n # mount in read-only mode (safer)\n mount_options = [\"ro\"]\n\n # add \"nolock\" if it's a NFS share (bnc#433893)\n if used_fs == :nfs\n Builtins.y2milestone(\"Mounting NFS with 'nolock' option\")\n mount_options = Builtins.add(mount_options, \"nolock\")\n end\n\n # join the options\n mount_options_str = Builtins.mergestring(mount_options, \",\")\n\n mount_command = Builtins.sformat(\n \"/bin/mount -o %1 %2 %3\",\n mount_options_str,\n Ops.get_string(part, \"device\", \"\"),\n tmpdir\n )\n\n Builtins.y2milestone(\n \"Executing mount command: %1\",\n mount_command\n )\n\n result = Convert.to_integer(\n SCR.Execute(path(\".target.bash\"), mount_command)\n )\n Builtins.y2milestone(\"Mount result: %1\", result)\n\n if result == 0\n partition = Convert.convert(\n SCR.Read(path(\".run.df\")),\n :from => \"any\",\n :to => \"list <map <string, string>>\"\n )\n Builtins.foreach(partition) do |p|\n if Ops.get_string(p, \"name\", \"\") == tmpdir\n Builtins.y2internal(\"P: %1\", p)\n free_size = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"free\", \"0\")),\n 1024\n )\n used = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"used\", \"0\")),\n 1024\n )\n end\n end\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"/bin/umount %1\", tmpdir)\n )\n else\n Builtins.y2error(\n \"Mount failed, ignoring partition %1\",\n Ops.get_string(part, \"device\", \"\")\n )\n @failed_mounts = Builtins.add(@failed_mounts, part)\n\n next\n end\n else\n # for formatted partitions estimate free system size\n # compute fs overhead\n used = EstimateFsOverhead(part)\n\n if Ops.greater_than(used, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming fs overhead: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(used, 1024)\n )\n end\n\n # journal size\n js = 0\n\n if ExtFs(used_fs)\n js = ExtJournalSize(part)\n reserved = ReservedSpace(part)\n\n if Ops.greater_than(reserved, 0)\n used = Ops.add(used, reserved)\n end\n elsif used_fs == :xfs\n js = XfsJournalSize(part)\n elsif used_fs == :reiser\n js = ReiserJournalSize(part)\n elsif used_fs == :jfs\n js = JfsJournalSize(part)\n else\n Builtins.y2warning(\n \"Unknown journal size for filesystem: %1\",\n used_fs\n )\n end\n\n if Ops.greater_than(js, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming journal size: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(js, 1024)\n )\n used = Ops.add(used, js)\n end\n\n # decrease free size\n free_size = Ops.subtract(free_size, used)\n\n # check for underflow\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n end\n\n # convert into kB for TargetInitDU\n free_size = Ops.divide(free_size, 1024)\n used = Ops.divide(used, 1024)\n\n Builtins.y2milestone(\n \"available partition: mount: %1, free: %2 KB, used: %3 KB\",\n Ops.get_string(part, \"mount\", \"\"),\n free_size,\n used\n )\n if !remove_slash\n target_partitions = Builtins.add(\n target_partitions,\n {\n \"name\" => Ops.get_string(part, \"mount\", \"\"),\n \"used\" => used,\n \"free\" => free_size\n }\n )\n else\n part_name = \"\"\n mount_name = Ops.get_string(part, \"mount\", \"\")\n\n if mount_name != \"/\"\n part_name = Builtins.substring(\n mount_name,\n 1,\n Builtins.size(mount_name)\n )\n else\n part_name = mount_name\n end\n\n target_partitions = Builtins.add(\n target_partitions,\n { \"name\" => part_name, \"used\" => used, \"free\" => free_size }\n )\n end\n end\n end\n end\n end # foreach (`part)\n end # foreach (`disk)\n\n # add estimated size occupied by non-package files\n target_partitions = EstimateTargetUsage(target_partitions)\n\n Builtins.y2milestone(\"get_partition_info: part %1\", target_partitions)\n Pkg.TargetInitDU(target_partitions)\n\n deep_copy(target_partitions)\n end",
"def partition_used(partition)\n # Return magic number if in test_mode to prevent syscall\n return '128' if @test_mode\n b = ' ' * 128\n syscall(137, partition, b)\n a = b.unpack('QQQQQ')\n [a[2] * blocks_per_kilobyte, a[4] * blocks_per_kilobyte]\n end",
"def profile_types(prov_type)\n case prov_type.to_sym\n when :appstore\n return [\n Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_STORE,\n Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE,\n Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_STORE,\n Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE\n ]\n when :development\n return [\n Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT,\n Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT,\n Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT,\n Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT\n ]\n when :enterprise\n return [\n Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE,\n Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE\n ]\n when :adhoc\n return [\n Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC,\n Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC\n ]\n when :developer_id\n return [\n Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT,\n Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT\n ]\n else\n raise \"Unknown provisioning type '#{prov_type}'\"\n end\n end",
"def parts_on?(device)\n partitions = lsblk(device)\n return true if partitions[0]['type'] == 'part'\n\n false\n end",
"def list_size_nix_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"83\") print $5;else {if ($5==\"83\") print $4}}' | sed s/+//g`.chomp.split\nend",
"def all_devices search = nil\n partitions = []\n devices = []\n device = nil\n has_extended = false\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"lsblk\"\n params = \" #{search} -b -P -o VENDOR,MODEL,TYPE,SIZE,KNAME,UUID,LABEL,MOUNTPOINT,FSTYPE,RM\"\n end\n lsblk = CommandsExecutor.new command, params\n lsblk.execute\n raise \"Command execution error: #{lsblk.stderr.read}\" if not lsblk.success?\n\n lsblk.result.each_line do |line|\n data_hash = {}\n line.squish!\n line_data = line.gsub!(/\"(.*?)\"/, '\\1#').split \"#\"\n line_data.each do |data|\n data.strip!\n key, value = data.split \"=\"\n data_hash[key.downcase] = value\n end\n data_hash['rm'] = data_hash['rm'].to_i # rm = 1 if device is a removable/flash device, otherwise 0\n if data_hash['type'] == 'mpath'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n if device\n multipath_info = {'mkname' => data_hash['kname'], 'multipath' => true, 'size' => data_hash['size']}\n device.merge! multipath_info\n else\n data_hash['multipath'] = true\n device = data_hash\n devices.push device\n end\n next\n end\n if data_hash['type'] == 'disk'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n unless device.nil?\n device['partitions'] = partitions\n partitions = []\n devices.push device\n device = nil # cleanup the variable\n end\n device = data_hash\n next\n end\n if data_hash['type'] == 'part'\n data_hash.except!('model', 'vendor')\n data_hash.merge! self.usage data_hash['kname']\n\n partition_number = get_partition_number \"/dev/#{data_hash['kname']}\" # For reference: data_hash['kname'].match(/[0-9]*$/)[0].to_i\n extended_partition_types = ['0x05'.hex, '0x0F'.hex]\n if partition_type_hex(data_hash['kname']).in? extended_partition_types\n has_extended = true\n next\n end\n if has_extended and partition_number > 4\n data_hash['logical'] = true\n end\n # device['partitions'].nil? ? device['partitions'] = [data_hash] : device['partitions'].push(data_hash)\n partitions.push(data_hash)\n end\n end\n device['partitions'] = partitions if device\n devices.push device\n if search\n return devices.first || partitions.first\n else\n return devices\n end\n end",
"def disk_type\n return @disk_type\n end",
"def allowed_types\n\t\t[Domain,Device]\n\tend",
"def storage_only\n select {|d| d.resource_type == 17}\n end",
"def allowed_types\n\t\t[Device, Domain]\n\tend",
"def list_swap_partitions_with_size # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $1\":\"$5;else {if ($5==\"82\") print $1\":\"$4}}' | sed s/+//g`.chomp.split\nend",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def mime_types\n [].tap do |result|\n @parts.each do |part|\n result << part.content_type\n end\n end\n end",
"def get_current_devices(proc_partitions_output)\n lines = proc_partitions_output.split(\"\\n\")\n partitions = lines.drop(2).map do |line|\n line.chomp.split.last\n end.reject do |partition|\n partition =~ /^dm-\\d/\n end\n devices = partitions.select do |partition|\n partition =~ /[a-z]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n if devices.empty?\n devices = partitions.select do |partition|\n partition =~ /[0-9]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n end\n devices\n end",
"def list_size_swap_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $5;else {if ($5==\"82\") print $4}}' | sed s/+//g`.chomp\nend",
"def create_types\n\t\t[Device]\n\tend",
"def create_types\n\t\t[Device]\n\tend",
"def split_partitions\n partition_names = @list.map { |bin| bin.partition_names }.flatten\n partition_names.select { |name| partition_names.index(name) != partition_names.rindex(name) }.uniq\n end",
"def partitioned_tables\n PartitionedTables.new(connection).all\n end",
"def partition_list()\nend",
"def supported_extensions\n\t\treturn self.supported_extension_oids.collect {|oid| EXTENSION_NAMES[oid] || oid }\n\tend",
"def create_partitions\n info(\"Creating disk with #{PARTITION_TABLE_TYPE} parition table\")\n execute!(\"parted -s #{@dev} mklabel #{PARTITION_TABLE_TYPE}\")\n\n start_size = FIRST_PARTITION_OFFSET\n end_size = FIRST_PARTITION_OFFSET\n\n unspec_part = nil\n\n # Create the partitions\n @partition_layout.each_with_index do |part, index|\n # Deal with any \"open ended\" partitions last\n if not part.size_mb.is_a?(Integer)\n unspec_part = part\n next\n end\n\n start_size = end_size\n end_size += part.size_mb\n\n info(\"Creating partition #{part.label} (#{part.fs}, #{part.size_mb}MiB)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{start_size}MiB #{end_size}MiB\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{index + 1} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n\n if not part.fs\n warn(\"No filesystem specified for #{part.label}. Skipping FS\")\n else\n create_filesystem(part.fs, label_path, part.label)\n end\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n # Deal with any \"open ended\" partitions (that have an unspecified size_mb)\n if unspec_part\n part = unspec_part\n info(\"Creating partition #{part.label} (#{part.fs}, 100% remaining)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{end_size}MiB 100%\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{@partition_layout.length} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n create_filesystem(part.fs, label_path, part.label) if part.fs\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n nil\n end",
"def FSCKPartition(partition)\n if !Mode.test\n detected_fs = Storage.DetectFs(partition)\n if detected_fs == :ext2\n # label, %1 is partition\n out = Builtins.sformat(_(\"Checking partition %1\"), partition)\n UI.OpenDialog(Opt(:decorated), Label(out))\n\n Builtins.y2milestone(\"command: /sbin/e2fsck -y %1\", partition)\n SCR.Execute(\n path(\".target.bash\"),\n Ops.add(\"/sbin/e2fsck -y \", partition)\n )\n\n UI.CloseDialog\n end\n end\n\n nil\n end",
"def list_nix_partitions_with_size # nelsongs \n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"83\") print $1\":\"$5;else {if ($5==\"83\") print $1\":\"$4}}' | sed s/+//g`.chomp.split\nend",
"def conf_media_type\n @conf_kit_media_types = Kitting::KitMediaType.where(:kit_type => \"configurable\",:customer_number => \"SYSTEM\")\n end",
"def software_mm_comp_file_types\n %w[b f g i]\n end",
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def get_filetype(partition) # by nelsongs\n\treturn `file -s \"#{partition}\" | awk '{print $2}'`.chomp\nend",
"def drive_type; end",
"def software_types\n types = []\n self['852j'].each do |j|\n if j =~ /\\Acd-?rom/i\n types << 'CR'\n end\n if j =~ /\\Asoftware/i\n types << 'CS'\n end\n end\n types.uniq!\n return types\n end",
"def GetPartitionInfo\n partition = []\n\n if Stage.cont\n partition = EvaluateFreeSpace(0) # free spare already checked during first part of installation\n elsif Mode.update\n partition = EvaluateFreeSpace(15) # 15% free spare for update/upgrade\n elsif Mode.normal\n partition = EvaluateFreeSpace(5) # 5% free spare for post installation # Stage::initial ()\n else\n partition = get_partition_info\n end\n Builtins.y2milestone(\n \"INIT done, SpaceCalculation - partitions: %1\",\n partition\n )\n\n @info_called = true\n @partition_info = deep_copy(partition) # store partition_info\n\n deep_copy(partition)\n end",
"def provisioners(type, env)\n env[:machine].config.vm.provisioners.select do |provisioner|\n # Vagrant 1.7 changes provisioner.name to provisioner.type\n if provisioner.respond_to? :type\n provisioner.type.to_sym == type\n else\n provisioner.name.to_sym == type\n end\n end\n end",
"def get_supported_file_types\n path = '/v3/miscellaneous/supported-file-types'\n\n headers = {\n 'Content-Type' => 'application/json',\n 'User-Agent' => Config.user_agent\n }\n\n request = Net::HTTP::Get.new(path, headers)\n handle_response(@api_client.request(request), 'get_supported_file_types')\n end",
"def extensions\n extensions_size = MemoryPointer::new( :size_t )\n error = OpenCL.clGetPlatformInfo( self, EXTENSIONS, 0, nil, extensions_size)\n error_check(error)\n ext = MemoryPointer::new( extensions_size.read_size_t )\n error = OpenCL.clGetPlatformInfo( self, EXTENSIONS, extensions_size.read_size_t, ext, nil)\n error_check(error)\n ext_string = ext.read_string\n return ext_string.split(\" \")\n end",
"def os_type\n vm.storage_profile.os_disk.os_type\n end",
"def selected_mime_types\n return [] if mime_types.blank?\n\n mime_types.split(',')\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def physical_disk_views\n client.enumerate(\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/DCIM/DCIM_PhysicalDiskView\")\n end",
"def scoped_medium_types\n [primary_media.prepend('primary'), secondary_media.prepend('secondary'), component_media.prepend('component')]\n end",
"def content_types\n self.mounting_point.content_types\n end",
"def human_types\n types.map { |type| Core::TYPES_DESC[type] }\n end",
"def guest_types_descriptions\n {\n \"dosGuest\" => \"Microsoft MS-DOS\",\n \"win31Guest\" => \"Microsoft Windows 3.1\",\n \"win95Guest\" => \"Microsoft Windows 95\",\n \"win98Guest\" => \"Microsoft Windows 98\",\n \"winMeGuest\" => \"Microsoft Windows Millenium Edition\",\n \"winNTGuest\" => \"Microsoft Windows NT\",\n \"win2000ProGuest\" => \"Microsoft Windows 2000 Professional\",\n \"win2000ServGuest\" => \"Microsoft Windows 2000 Server\",\n \"win2000AdvServGuest\" => \"Microsoft Windows 2000 Advanced Server\",\n \"winXPHomeGuest\" => \"Microsoft Windows XP Home Edition\",\n \"winXPProGuest\" => \"Microsoft Windows XP Professional (32-bit)\",\n \"winXPPro64Guest\" => \"Microsoft Windows XP Professional (64-bit)\",\n \"winNetWebGuest\" => \"Microsoft Windows Server 2003 Web Edition (32-bit)\",\n \"winNetStandardGuest\" => \"Microsoft Windows Server 2003 Standard Edition (32-bit)\",\n \"winNetEnterpriseGuest\" => \"Microsoft Windows Server 2003 Enterprise Edition (32-bit)\",\n \"winNetDatacenterGuest\" => \"Microsoft Windows Server 2003 Datacenter Edition (32-bit)\",\n \"winNetBusinessGuest\" => \"Microsoft Windows Small Business Server 2003\",\n \"winNetStandard64Guest\" => \"Microsoft Windows Server 2003 Standard Edition (64-bit)\",\n \"winNetEnterprise64Guest\" => \"Microsoft Windows Server 2003 Enterprise Edition (64-bit)\",\n \"winLonghornGuest\" => \"Microsoft Windows Longhorn (32-bit)\",\n \"winLonghorn64Guest\" => \"Microsoft Windows Longhorn (64-bit)\",\n \"winNetDatacenter64Guest\" => \"Microsoft Windows Server 2003 Datacenter Edition (64-bit)\",\n \"winVistaGuest\" => \"Microsoft Windows Vista (32-bit)\",\n \"winVista64Guest\" => \"Microsoft Windows Vista (64-bit)\",\n \"windows7Guest\" => \"Microsoft Windows 7 (32-bit)\",\n \"windows7_64Guest\" => \"Microsoft Windows 7 (64-bit)\",\n \"windows7Server64Guest\" => \"Microsoft Windows Server 2008 R2 (64-bit)\",\n \"windows8Guest\" => \"Microsoft Windows 8 (32-bit)\",\n \"windows8_64Guest\" => \"Microsoft Windows 8 (64-bit)\",\n \"windows8Server64Guest\" => \"Microsoft Windows Server 2012 (64-bit)\",\n \"windowsHyperVGuest\" => \"Microsoft Windows Hyper-V\",\n \"freebsd64Guest\" => \"FreeBSD (64-bit)\",\n \"freebsdGuest\" => \"FreeBSD (32-bit)\",\n \"redhatGuest\" => \"Red Hat Linux 2.1\",\n \"rhel2Guest\" => \"Red Hat Enterprise Linux 2.1\",\n \"rhel3Guest\" => \"Red Hat Enterprise Linux 3 (32-bit)\",\n \"rhel3_64Guest\" => \"Red Hat Enterprise Linux 3 (64-bit)\",\n \"rhel4Guest\" => \"Red Hat Enterprise Linux 4 (32-bit)\",\n \"rhel4_64Guest\" => \"Red Hat Enterprise Linux 4 (64-bit)\",\n \"rhel5Guest\" => \"Red Hat Enterprise Linux 5 (32-bit)\",\n \"rhel5_64Guest\" => \"Red Hat Enterprise Linux 5 (64-bit)\",\n \"rhel6Guest\" => \"Red Hat Enterprise Linux 6 (32-bit)\",\n \"rhel6_64Guest\" => \"Red Hat Enterprise Linux 6 (64-bit)\",\n \"rhel7Guest\" => \"Red Hat Enterprise Linux 7 (32-bit)\",\n \"rhel7_64Guest\" => \"Red Hat Enterprise Linux 7 (64-bit)\",\n \"centosGuest\" => \"CentOS 4/5/6 (32-bit)\",\n \"centos64Guest\" => \"CentOS 4/5/6 (64-bit)\",\n \"oracleLinux64Guest\" => \"Oracle Linux 4/5/6 (64-bit)\",\n \"oracleLinuxGuest\" => \"Oracle Linux 4/5/6 (32-bit)\",\n \"suseGuest\" => \"Suse Linux (32-bit)\",\n \"suse64Guest\" => \"Suse Linux (64-bit)\",\n \"slesGuest\" => \"Novell SUSE Linux Enterprise 8/9 (32-bit)\",\n \"sles64Guest\" => \"Novell SUSE Linux Enterprise 8/9 (64-bit)\",\n \"sles10Guest\" => \"Novell SUSE Linux Enterprise 10 (32-bit)\",\n \"sles10_64Guest\" => \"Novell SUSE Linux Enterprise 10 (64-bit)\",\n \"sles11Guest\" => \"Novell SUSE Linux Enterprise 11 (32-bit)\",\n \"sles11_64Guest\" => \"Novell SUSE Linux Enterprise 11 (64-bit)\",\n \"sles12Guest\" => \"Novell SUSE Linux Enterprise 12 (32-bit)\",\n \"sles12_64Guest\" => \"Novell SUSE Linux Enterprise 12 (64-bit)\",\n \"nld9Guest\" => \"Novell Linux Desktop 9\",\n \"oesGuest\" => \"Novell Open Enterprise Server\",\n \"sjdsGuest\" => \"Sun Java Desktop System\",\n \"mandrakeGuest\" => \"Mandrake Linux\",\n \"mandrivaGuest\" => \"Mandriva Linux (32-bit)\",\n \"mandriva64Guest\" => \"Mandriva Linux (64-bit)\",\n \"turboLinuxGuest\" => \"Turbolinux (32-bit)\",\n \"turboLinux64Guest\" => \"Turbolinux (64-bit)\",\n \"ubuntu64Guest\" => \"Ubuntu Linux (64-bit)\",\n \"ubuntuGuest\" => \"Ubuntu Linux (32-bit)\",\n \"debian4Guest\" => \"Debian GNU/Linux 4 (32-bit)\",\n \"debian4_64Guest\" => \"Debian GNU/Linux 5 (64-bit)\",\n \"debian5Guest\" => \"Debian GNU/Linux 5 (32-bit)\",\n \"debian5_64Guest\" => \"Debian GNU/Linux 5 (64-bit)\",\n \"debian6Guest\" => \"Debian GNU/Linux 6 (32-bit)\",\n \"debian6_64Guest\" => \"Debian GNU/Linux 6 (64-bit)\",\n \"debian7Guest\" => \"Debian GNU/Linux 7 (32-bit)\",\n \"debian7_64Guest\" => \"Debian GNU/Linux 7 (64-bit)\",\n \"asianux3Guest\" => \"Asianux Server 3 (32-bit)\",\n \"asianux3_64Guest\" => \"Asianux Server 3 (64-bit)\",\n \"asianux4Guest\" => \"Asianux Server 4 (32-bit)\",\n \"asianux4_64Guest\" => \"Asianux Server 4 (64-bit)\",\n \"opensuseGuest\" => \"OpenSUSE Linux (32-bit)\",\n \"opensuse64Guest\" => \"OpenSUSE Linux (64-bit)\",\n \"fedoraGuest\" => \"Fedora Linux\",\n \"fedora64Guest\" => \"Fedora Linux (64-bit)\",\n \"other24xLinuxGuest\" => \"Other 2.4.x Linux (32-bit)\",\n \"other26xLinuxGuest\" => \"Other 2.6.x Linux (32-bit)\",\n \"other3xLinuxGuest\" => \"Other Linux 3.x Guest\",\n \"otherLinuxGuest\" => \"Other Linux (32-bit)\",\n \"genericLinuxGuest\" => \"Other Linux\",\n \"other24xLinux64Guest\" => \"Other 2.4.x Linux (64-bit)\",\n \"other26xLinux64Guest\" => \"Other 2.6.x Linux (64-bit)\",\n \"other3xLinux64Guest\" => \"Other Linux 3.x Guest (64-bit)\",\n \"otherLinux64Guest\" => \"Other Linux (64-bit)\",\n \"solaris6Guest\" => \"Sun Microsystems Solaris 6\",\n \"solaris7Guest\" => \"Sun Microsystems Solaris 7\",\n \"solaris8Guest\" => \"Sun Microsystems Solaris 8\",\n \"solaris9Guest\" => \"Sun Microsystems Solaris 9\",\n \"solaris10Guest\" => \"Oracle Solaris 10 (32-bit)\",\n \"solaris10_64Guest\" => \"Oracle Solaris 10 (64-bit)\",\n \"solaris11_64Guest\" => \"Oracle Solaris 11 (64-bit)\",\n \"os2Guest\" => \"IBM OS/2\",\n \"eComStationGuest\" => \"Serenity Systems eComStation 1.x\",\n \"eComStation2Guest\" => \"Serenity Systems eComStation 2.0\",\n \"netware4Guest\" => \"Novell NetWare 4\",\n \"netware5Guest\" => \"Novell NetWare 5.1\",\n \"netware6Guest\" => \"Novell NetWare 6.x\",\n \"openServer5Guest\" => \"SCO OpenServer 5\",\n \"openServer6Guest\" => \"SCO OpenServer 6\",\n \"unixWare7Guest\" => \"SCO UnixWare 7\",\n \"darwinGuest\" => \"Apple Mac OS X 10.5 (32-bit)\",\n \"darwin64Guest\" => \"Apple Mac OS X 10.5 (64-bit)\",\n \"darwin10Guest\" => \"Apple Mac OS X 10.6 (32-bit)\",\n \"darwin10_64Guest\" => \"Apple Mac OS X 10.6 (64-bit)\",\n \"darwin11Guest\" => \"Apple Mac OS X 10.7 (32-bit)\",\n \"darwin11_64Guest\" => \"Apple Mac OS X 10.7 (64-bit)\",\n \"darwin12_64Guest\" => \"Mac OS 10.8 (64-bit)\",\n \"darwin13_64Guest\" => \"Mac OS 10.9 (64-bit)\",\n \"vmkernelGuest\" => \"VMWare ESX 4.x\",\n \"vmkernel5Guest\" => \"VMWare ESXi 5.x\",\n \"otherGuest\" => \"Other (32-bit)\",\n \"otherGuest64\" => \"Other (64-bit)\"\n }\n end",
"def drive_type\n return @drive_type\n end",
"def drive_type\n return @drive_type\n end",
"def diff_types\n\t\t\tavailable = []\n\n\t\t\tif @parent.file_1.contains_found? and @parent.file_2.contains_found? then\n\t\t\t\tavailable.push :direct\n\t\t\tend\n\n\n\t\t\tif available.empty? then\n\t\t\t\tavailable.push :notAvailable\n\t\t\tend\n\t\t\treturn available\n\t\tend",
"def get_available_pnics\n pnics_in_use = []\n pnics_available = []\n\n # Get pnics in use in standard switches\n @item.config.network.vswitch.each do |vs|\n vs.pnic.each do |pnic|\n pnic.slice!(\"key-vim.host.PhysicalNic-\")\n pnics_in_use << pnic\n end\n end\n\n # Get pnics in host\n self['config.network'].pnic.each do |pnic|\n pnics_available << pnic.device if !pnics_in_use.include?(pnic.device)\n end\n\n return pnics_available\n end",
"def drive_type\n fetch('vehicle.drive_types')\n end",
"def filesystem_type(host)\n case host['platform']\n when %r{aix}\n 'jfs2'\n when %r{el-|centos|fedora|sles|debian|ubuntu}\n 'ext3'\n else\n # TODO: Add Solaris and OSX support, as per PUP-5201 and PUP-4823\n fail_test(\"Unable to determine a standard filesystem table type for #{host['platform']}\")\n end\n end",
"def edition_types\n @descriptive_detail.edition_types\n end",
"def disks\n return @disks unless @disks.empty?\n\n info_disks\n end",
"def SetFormatPartitions(fstabpart)\n fstabpart = deep_copy(fstabpart)\n # All storage devices\n target_map = Storage.GetTargetMap\n\n # all activated\n tmp = Builtins.filter(RootPart.GetActivated) do |e|\n Ops.get_string(e, :type, \"\") == \"mount\" ||\n Ops.get_string(e, :type, \"\") == \"swap\"\n end\n\n Builtins.foreach(tmp) do |e|\n mntpt = Ops.get_string(e, :type, \"\") == \"swap\" ?\n \"swap\" :\n Ops.get_string(e, :mntpt, \"\")\n part = Ops.get_string(e, :device, \"\")\n p = {}\n Builtins.foreach(fstabpart) do |pp|\n # mountpoint matches\n if Ops.get_string(pp, \"mount\", \"\") == mntpt\n p = deep_copy(pp)\n raise Break\n end\n end\n mount_options = \"\"\n Builtins.foreach(Storage.ReadFstab(Installation.destdir)) do |entry|\n if Ops.get_string(entry, \"file\", \"\") == mntpt\n mount_options = Ops.get_string(entry, \"mntops\", \"\")\n raise Break\n end\n end\n target_map = Storage.SetPartitionData(target_map, part, \"mount\", mntpt)\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"format\",\n Ops.get_boolean(p, \"format\", false)\n )\n target_map = Storage.SetPartitionData(target_map, part, \"delete\", false)\n target_map = Storage.SetPartitionData(target_map, part, \"create\", false)\n if Builtins.haskey(p, \"filesystem\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"filesystem\",\n Ops.get_symbol(p, \"filesystem\", :ext4)\n )\n end\n if Ops.greater_than(Builtins.size(mount_options), 0) &&\n !Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n mount_options\n )\n end\n if Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n Ops.get_string(p, \"fstopt\", \"\")\n )\n end\n if Builtins.haskey(p, \"mountby\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"mountby\",\n Ops.get_symbol(p, \"mountby\", :device)\n )\n end\n end\n\n Storage.SetTargetMap(target_map)\n true\n end",
"def GetOtherLinuxPartitions\n ret = []\n Builtins.foreach(GetTargetMap()) do |dev, disk|\n if IsPartitionable(disk)\n l = Builtins.filter(Ops.get_list(disk, \"partitions\", [])) do |p|\n !Ops.get_boolean(p, \"format\", false) &&\n Partitions.IsLinuxPartition(Ops.get_integer(p, \"fsid\", 0))\n end\n l = Builtins.filter(l) do |p|\n Builtins.contains(\n [:xfs, :ext2, :ext3, :ext4, :btrfs, :jfs, :reiser],\n Ops.get_symbol(p, \"used_fs\", :unknown)\n )\n end\n l = Builtins.filter(l) do |p|\n !FileSystems.IsSystemMp(Ops.get_string(p, \"mount\", \"\"), false)\n end\n ret = Builtins.union(ret, l) if Ops.greater_than(Builtins.size(l), 0)\n end\n end\n Builtins.y2milestone(\"GetOtherLinuxPartitions ret=%1\", ret)\n deep_copy(ret)\n end",
"def fs_types_to_backup\n regex=Regexp.new(@skip_fs_regex)\n fs=%x[#{fs_types_cmd}] \n fs.split.reject {|x| regex =~ x}\n end",
"def options_for_supported_types\n Mapping::SUPPORTED_TYPES.map do |type|\n [type.titleize.to_s, type]\n end\n end",
"def operating_systems\n collect\n end",
"def setPartitionType(settings)\n settings = deep_copy(settings)\n tm = Storage.GetTargetMap\n settings = Builtins.maplist(settings) do |d|\n if Ops.get_symbol(d, \"type\", :x) == :CT_DISK\n mp = Ops.get_integer(\n tm,\n [Ops.get_string(d, \"device\", \"xxx\"), \"max_primary\"],\n 0\n )\n if Ops.greater_than(mp, 0)\n Ops.set(\n d,\n \"partitions\",\n Builtins.maplist(Ops.get_list(d, \"partitions\", [])) do |pe|\n if Builtins.haskey(pe, \"partition_nr\") &&\n !Builtins.haskey(pe, \"partition_type\") &&\n Ops.less_or_equal(\n Ops.get_integer(pe, \"partition_nr\", -1),\n mp\n )\n Ops.set(pe, \"partition_type\", \"primary\")\n end\n deep_copy(pe)\n end\n )\n end\n end\n deep_copy(d)\n end\n Builtins.y2milestone(\"after setPartitionType = %1\", settings)\n deep_copy(settings)\n end",
"def media_types\n return @media_types\n end",
"def deleteAllDevPartitions(disk, installation)\n disk = deep_copy(disk)\n go_on = true\n del_dev = Ops.get_string(disk, \"device\", \"\")\n Builtins.y2milestone(\n \"deleteAllDevPartitions disk:%1\",\n Builtins.remove(disk, \"partitions\")\n )\n\n #///////////////////////////////////////////////////////////////\n # check mount points if not installation\n\n if !installation\n mounts = Storage.mountedPartitionsOnDisk(del_dev)\n if Builtins.size(mounts) != 0\n #///////////////////////////////////////////////////////\n # mount points found\n\n mounted_parts = \"\"\n Builtins.foreach(mounts) do |mount|\n # %1 is replaced by device name, %1 by directory e.g /dev/hdd1 on /opt\n mounted_parts = Ops.add(\n Ops.add(\n mounted_parts,\n Builtins.sformat(\n \"%1 on %2\",\n Ops.get_string(mount, \"device\", \"\"),\n Ops.get_string(mount, \"mount\", \"\")\n )\n ),\n \"\\n\"\n )\n end\n\n # popup text, %1 is replaced by device name\n message = Builtins.sformat(\n _(\n \"The selected device contains partitions that are currently mounted:\\n\" +\n \"%1\\n\" +\n \"We *strongly* recommended to unmount these partitions before deleting the partition table.\\n\" +\n \"Choose Cancel unless you know exactly what you are doing.\\n\"\n ),\n mounted_parts\n )\n\n go_on = false if !Popup.ContinueCancel(message)\n end\n end\n\n if go_on\n partitions = Ops.get_list(disk, \"partitions\", [])\n\n used = check_devices_used(partitions, false)\n\n go_on = used == :UB_NONE\n\n if used == :UB_LVM\n # popup text, Do not translate LVM.\n Popup.Message(\n _(\n \"\\n\" +\n \"The selected device contains at least one LVM partition\\n\" +\n \"assigned to a volume group. Remove all\\n\" +\n \"partitions from their respective volume groups\\n\" +\n \"before deleting the device.\\n\"\n )\n )\n elsif used == :UB_MD\n # popup text, Do not translate RAID.\n Popup.Message(\n _(\n \"\\n\" +\n \"The selected device contains at least one partition\\n\" +\n \"that is part of a RAID system. Unassign the\\n\" +\n \"partitions from their respective RAID systems before\\n\" +\n \"deleting the device.\\n\"\n )\n )\n elsif used != :UB_NONE\n # popup text\n Popup.Message(\n _(\n \"\\n\" +\n \"The selected device contains at least one partition\\n\" +\n \"that is used by another volume. Delete the volume using it\\n\" +\n \"before deleting the device.\\n\"\n )\n )\n end\n\n if go_on && Ops.get_symbol(disk, \"type\", :CT_UNKNONW) != :CT_DMRAID\n #///////////////////////////////////////////////\n # delete all partitions of disk\n # logical partitions get removed when extended is deleted\n dp = Builtins.filter(partitions) do |part|\n Ops.less_or_equal(\n Ops.get_integer(part, \"nr\", 0),\n Ops.get_integer(disk, \"max_primary\", 4)\n )\n end\n Builtins.y2milestone(\"deleteAllDevPartitions dp:%1\", dp)\n dp = Builtins.sort(dp) do |a, b|\n Ops.greater_than(\n Ops.get_integer(a, \"nr\", 0),\n Ops.get_integer(b, \"nr\", 0)\n )\n end\n Builtins.y2milestone(\"deleteAllDevPartitions dp:%1\", dp)\n Builtins.foreach(dp) do |part|\n go_on = go_on &&\n Storage.DeleteDevice(Ops.get_string(part, \"device\", \"\"))\n end\n end\n end\n Builtins.y2milestone(\"deleteAllDevPartitions ret:%1\", go_on)\n go_on\n end",
"def supported_extension_oids\n\t\treturn self.root_dse[:supportedExtension]\n\tend",
"def list\n \n @product_types = ProductType.find(:all, :order => \"name\")\n end",
"def MountUserDefinedVarPartition\n # function return value\n manual_mount_successful = false\n\n list_of_devices = []\n # $[ \"/dev/sda3\" : \"Label: My_Partition\" ]\n device_info = {}\n\n # Creating the list of known partitions\n Builtins.foreach(Storage.GetOndiskTarget) do |device, description|\n Builtins.foreach(Ops.get_list(description, \"partitions\", [])) do |partition|\n # Some partitions logically can't be used for /var\n next if Ops.get_symbol(partition, \"detected_fs\", :unknown) == :swap\n next if Ops.get_symbol(partition, \"type\", :unknown) == :extended\n next if !Builtins.haskey(partition, \"device\")\n list_of_devices = Builtins.add(\n list_of_devices,\n Ops.get_string(partition, \"device\", \"\")\n )\n Ops.set(\n device_info,\n Ops.get_string(partition, \"device\", \"\"),\n Builtins.sformat(\n # Informational text about selected partition, %x are replaced with values later\n _(\n \"<b>File system:</b> %1, <b>Type:</b> %2,<br>\\n\" +\n \"<b>Label:</b> %3, <b>Size:</b> %4,<br>\\n\" +\n \"<b>udev IDs:</b> %5,<br>\\n\" +\n \"<b>udev path:</b> %6\"\n ),\n # starts with >`<\n Builtins.substring(\n Builtins.tostring(\n Ops.get_symbol(partition, \"detected_fs\", :unknown)\n ),\n 1\n ),\n Ops.get_locale(partition, \"fstype\", _(\"Unknown\")),\n Ops.get_locale(partition, \"label\", _(\"None\")),\n String.FormatSize(\n Ops.multiply(Ops.get_integer(partition, \"size_k\", 0), 1024)\n ),\n Builtins.mergestring(Ops.get_list(partition, \"udev_id\", []), \", \"),\n Ops.get_locale(partition, \"udev_path\", _(\"Unknown\"))\n )\n )\n end\n end\n\n list_of_devices = Builtins.sort(list_of_devices)\n Builtins.y2milestone(\"Known devices: %1\", list_of_devices)\n\n while true\n UI.OpenDialog(\n VBox(\n MarginBox(\n 1,\n 0,\n VBox(\n # a popup caption\n Left(\n Heading(_(\"Unable to find the /var partition automatically\"))\n ),\n # a popup message\n Left(\n Label(\n _(\n \"Your system uses a separate /var partition which is required for the upgrade\\n\" +\n \"process to detect the disk-naming changes. Select the /var partition manually\\n\" +\n \"to continue the upgrade process.\"\n )\n )\n ),\n VSpacing(1),\n Left(\n ComboBox(\n Id(\"var_device\"),\n Opt(:notify),\n # a combo-box label\n _(\"&Select /var Partition Device\"),\n list_of_devices\n )\n ),\n VSpacing(0.5),\n # an informational rich-text widget label\n Left(Label(_(\"Device Info\"))),\n MinHeight(3, RichText(Id(\"device_info\"), \"\")),\n VSpacing(1)\n )\n ),\n MarginBox(\n 1,\n 0,\n ButtonBox(\n PushButton(Id(:ok), Opt(:okButton), Label.OKButton),\n PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton)\n )\n )\n )\n )\n\n ret = nil\n\n # initial device\n var_device = Convert.to_string(UI.QueryWidget(Id(\"var_device\"), :Value))\n UI.ChangeWidget(\n Id(\"device_info\"),\n :Value,\n Ops.get(device_info, var_device, \"\")\n )\n\n # to handle switching the combo-box or [OK]/[Cancel]\n while true\n ret = UI.UserInput\n var_device = Convert.to_string(\n UI.QueryWidget(Id(\"var_device\"), :Value)\n )\n\n if ret == \"var_device\"\n UI.ChangeWidget(\n Id(\"device_info\"),\n :Value,\n Ops.get(device_info, var_device, \"\")\n )\n else\n break\n end\n end\n\n UI.CloseDialog\n\n # Trying user-selection\n if ret == :ok\n Builtins.y2milestone(\"Trying to mount %1 as /var\", var_device)\n mount_error = MountVarPartition(var_device)\n\n if mount_error != nil\n Report.Error(mount_error)\n next\n else\n Builtins.y2milestone(\"Manual mount (/var) successful\")\n manual_mount_successful = true\n break\n end \n # `cancel\n else\n Builtins.y2warning(\n \"User doesn't want to enter the /var partition device\"\n )\n break\n end\n end\n\n manual_mount_successful\n end",
"def to_s\n \"<TopicPartitionList: #{to_h}>\"\n end",
"def node_types\n schema.possible_types(node_interface)\n end",
"def possible_types\n @data.flat_map { |iso2, data| data[:possible] }.uniq\n end",
"def partition_devices(device_list, attempt = 0, max_attempts = 3)\n return false if attempt >= max_attempts\n\n puts case attempt\n when 0 then \"Partioning devices ...\" \n else \"Retrying device partitioning (attempt #{attempt + 1}) ...\" \n end\n\n device_list.each do |device|\n puts \" * #{device}\"\n `echo 0|sfdisk #{device}`\n end\n\n puts \"Sleeping 10 seconds to reload partition tables ...\"\n sleep 10\n\n # Verify all volumes were properly partitioned\n missing_devices = []\n device_list.each do |device|\n missing_devices << device unless File.exists?(\"#{device}1\")\n end\n\n # Retry partitioning for failed volumes\n response = true\n if missing_devices.size > 0\n response = partition_devices(missing_devices, attempt + 1, max_attempts)\n end\n response\n end",
"def get_available_log_types\n @driver.logs.available_types\n end",
"def partitions(**opts)\n\t\t\t\topts[:disk]||=@computer.dig(:sysinit, :disk)\n\t\t\t\topts[:mountpoint]||=@computer.dig(:sysinit, :mountpoint)\n\t\t\t\t@partitions=partitions_helper(@partitions||Marshal.load(Marshal.dump(@computer.dig(:sysinit,:partitions))), **opts)\n\t\t\t\t@partitions = yield @partitions, **opts if block_given?\n\t\t\t\t@partitions\n\t\t\tend",
"def GetDiskPartition(device)\n Ops.get(GetDiskPartitionTg(device, GetTargetMap()), 0, {})\n end",
"def get_storage_names\n @schemas = self.get_schema\n @schemas.map { |schema| schema['id'] }\n end",
"def extensions\n TYPE_EXTS[type] || []\n end",
"def names\n fs = []\n %w( OUT_OF_ORDER_EXEC_MODE_ENABLE PROFILING_ENABLE ON_DEVICE ON_DEVICE_DEFAULT ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def available_formats\n formats = self.items.collect {|i| i.item_type }\n return formats.compact\n end"
] |
[
"0.7248117",
"0.63458914",
"0.62699544",
"0.6232824",
"0.61675614",
"0.6139866",
"0.60773873",
"0.6015134",
"0.59679866",
"0.59332496",
"0.58867615",
"0.5861007",
"0.58582693",
"0.58413965",
"0.5800998",
"0.5777511",
"0.5731578",
"0.56630963",
"0.56233054",
"0.56147826",
"0.56103384",
"0.55178386",
"0.55168283",
"0.5507805",
"0.5492134",
"0.54666305",
"0.54490125",
"0.5398466",
"0.53869927",
"0.5354423",
"0.5347855",
"0.5345301",
"0.5339228",
"0.5331605",
"0.5327201",
"0.5317739",
"0.53050447",
"0.52512467",
"0.5249122",
"0.5241754",
"0.52385175",
"0.52170676",
"0.5216961",
"0.5203627",
"0.5203627",
"0.51992655",
"0.5193717",
"0.51865417",
"0.5164607",
"0.51640916",
"0.51620424",
"0.5156103",
"0.5151367",
"0.51442224",
"0.51304114",
"0.5128535",
"0.5126386",
"0.5125024",
"0.5109948",
"0.5109935",
"0.51080894",
"0.510604",
"0.5100439",
"0.50932074",
"0.50786996",
"0.5068646",
"0.5066839",
"0.50491786",
"0.5048393",
"0.5040865",
"0.5040668",
"0.5040668",
"0.5037826",
"0.5037639",
"0.50225216",
"0.502022",
"0.5013217",
"0.50113666",
"0.500528",
"0.49980146",
"0.49925503",
"0.49864614",
"0.49846295",
"0.498011",
"0.49765792",
"0.49757597",
"0.49748534",
"0.49664652",
"0.4965666",
"0.49597973",
"0.4950336",
"0.49446458",
"0.49359524",
"0.49304757",
"0.49150246",
"0.49132985",
"0.49090308",
"0.49087313",
"0.49054456",
"0.49010772"
] |
0.75209886
|
0
|
Returns the parent Device if it exists
|
def parent_device_ext
ptr = MemoryPointer::new( Device )
error = OpenCL.clGetDeviceInfo(self, PARENT_DEVICE_EXT, Device.size, ptr, nil)
error_check(error)
return nil if ptr.null?
return Device::new(ptr.read_pointer)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parent_whole_disk\n Device.new('/dev/' + self['ParentWholeDisk'])\n end",
"def parent_object\n if has_parent?\n actual_class = parent_class_name.camelize.constantize\n actual_class.find(parent_id)\n else\n nil\n end\n end",
"def get_parent child_path\n parent_maj_min = nil\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"udevadm\"\n params = \" info --query=property --name=#{child_path}\"\n end\n udevadm = CommandsExecutor.new command, params\n udevadm.execute false, false # None blocking and not debug mode\n raise \"Command execution error: #{udevadm.stderr.read}\" if not udevadm.success?\n udevadm.result.each_line do |line|\n line.squish!\n key = 'ID_PART_ENTRY_DISK'\n _key, value = line.split '='\n parent_maj_min = value and break if _key.eql? key\n end\n\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"lsblk\"\n params = \" -b -P -o VENDOR,MODEL,TYPE,SIZE,KNAME,UUID,LABEL,MOUNTPOINT,FSTYPE,RM,MAJ:MIN\"\n end\n lsblk = CommandsExecutor.new command, params\n lsblk.execute\n raise \"Command execution error: #{lsblk.stderr.read}\" if not lsblk.success?\n lsblk.result.each_line do |line|\n data_hash = {}\n line.squish!\n line_data = line.gsub!(/\"(.*?)\"/, '\\1#').split \"#\"\n line_data.each do |data|\n data.strip!\n key, value = data.split \"=\"\n data_hash[key.downcase] = value\n return data_hash['kname'] if value == parent_maj_min\n end\n end\n raise \"Unable to find parent device for #{child_path}\"\n end",
"def parent\n o = Object.const_get(parent_model) rescue nil\n o && o.get(parent_id)\n end",
"def parent\n @parent ||= new_or_create? ? find_parent_by_id : lookup_parent_from_child\n end",
"def get_parent\n return nil\n end",
"def parent\n self.class.find_by_id(self.parent_id) unless self.parent_id.nil?\n end",
"def in_parent_hcard\n @in_parent_hcard ||= self.class.find_in_parent_hcard\n end",
"def parent\n if parent_id.blank? then nil else unscoped_find(parent_id) end\n end",
"def parent?\n !@child_pid.nil?\n end",
"def parent\n parents.empty? ? nil : parents[0]\n end",
"def parent\n tree.parent_for(parent_id).first\n end",
"def parent_object\n @parent_object ||= parent? && !parent_singleton? ? parent_model.find(parent_param) : nil\n end",
"def parent\n parent_path = @location.parent_path\n \n if parent_path.nil?\n nil\n else\n begin\n self.class.find(@conn_id, parent_path)\n rescue Errors::FolderNotFound, parent_path\n nil\n end\n end\n end",
"def parent\n\t\tpardn = self.parent_dn or return nil\n\t\treturn self.class.new( self.directory, pardn )\n\tend",
"def get_parent_object\n nil\n end",
"def current_parent\n\t Parent.where(id: session[\"parent_id\"]).first\n\tend",
"def find_parent_by\n self.class.find_parent_by || :id\n end",
"def parent\n has_parent? and history.first\n end",
"def parent\n object.try(:loaded)&.[](:parents)&.first || wayfinder.decorated_parent\n end",
"def parent?\n ! parent.nil?\n end",
"def parent\n nil\n end",
"def parent_resource\n @parent_resource ||=\n begin\n return nil if resource.try(:imported_metadata).present?\n Wayfinder.for(resource).parent\n end\n end",
"def has_parent?\n if !self.parent.nil?\n return self.parent\n else\n return false\n end\n end",
"def parent\n return nil unless catalog\n\n unless defined?(@parent)\n if parents = catalog.adjacent(self, :direction => :in)\n # We should never have more than one parent, so let's just ignore\n # it if we happen to.\n @parent = parents.shift\n else\n @parent = nil\n end\n end\n @parent\n end",
"def parent?\n not parent.nil?\n end",
"def parent?\n !parent.nil?\n end",
"def parent\n dataset.nested.filter(self.primary_key => self.parent_id).first if self.parent_id\n end",
"def has_parent?\n parent_id != nil\n end",
"def parent\n if @resource[:parent] =~ /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/\n gindex = $ngs.index { |i| i['id'] == @resource[:parent] }\n $ngs[gindex]['id']\n else\n @property_hash[:parent]\n end\n end",
"def get_parent_surface()\n get_parents().each do |findcommand|\n [\n \"EXTERIOR-WALL\",\n \"INTERIOR-WALL\",\n \"UNDERGROUND-WALL\",\n \"ROOF\"\n ].each do |type|\n\n if ( findcommand.commandName == type)\n return findcommand\n end\n end\n end\n raise(\"#no parent surface defined!\")\n end",
"def find_creator_parent_item\n ModelReference.find_where_referenced_from(self).first&.from_record\n end",
"def find_first_parent model = controller_model\n defined?(@first_parent) ? @first_parent : @first_parent = begin\n if parents = PARENTS[type_of(model)]\n parents.any? do |parent|\n id = params[:\"#{parent.name.underscore}_id\"]\n if id && parent.reflect_on_association(type_of(model))\n return parent.find(id)\n end\n end\n end\n end\n end",
"def parent_object\n # hack by sean to allow permalink parents\n parent? && !parent_singleton? ? parent_model_find(parent_param) : nil\n end",
"def parent\n @parent || NullResource.new\n end",
"def parent\n \tif self.parent_id == -1\n \t\treturn nil\n \telse\n \t\treturn Category.find(self.parent_id)\n \tend\n end",
"def parent_object_exists\n begin\n self.parent_class.constantize.find(self.parent_id)\n rescue\n self.errors.add(:parent_id,\"the #{self.parent_class} does not exist, Create it before trying to add an image to it\")\n end\n end",
"def has_parent?\n ! embedded['parent'].nil?\n end",
"def parent_document\n pi = parent_item\n return if pi == nil\n pi_id = pi.id\n return if pi_id == nil\n DocumentRepository.find(pi_id)\n end",
"def parent?\n true\n end",
"def device\n dev_entry = self.dev_node\n return nil if dev_entry.nil?\n return Device.new(dev_entry)\n end",
"def what_is_parent?\n puts @@classes[:parent]\n end",
"def parent_exists?\n parent.exist?\n end",
"def parent_exists?\n parent.exist?\n end",
"def has_parent?\n !parent.nil?\n end",
"def the_parent(content=nil)\n if node = content || @content || Content.get(params[:id])\n node.parent\n else\n \"<strong>Error:</strong> No parent information could be found\" unless ENV['RACK_ENV'] == 'production'\n end\n end",
"def parent?(id)\n self.parent_id == id\n end",
"def parent\n nil\n end",
"def parent?\n !parent_type.nil?\n end",
"def parent\n\n h.parent_id ?\n Ruote::Exp::FlowExpression.fetch(@context, h.parent_id) :\n nil\n end",
"def isParentChannel(child, parent)\n channel = @connection.call('channel.software.getDetails', @sid, child)\n return true if channel['parent_channel_label'] == parent\n false\n end",
"def get_parent_notification\n\t\tAuth.configuration.notification_class.constantize.find(self.parent_notification_id)\n\tend",
"def parent\n DataStore::Base.find(identifier: identifier)\n end",
"def parent?\n false\n end",
"def find_parent\n if params.key?(:reservation_id)\n @parent = @car.reservations.find(params[:reservation_id])\n elsif params.key?(:ride_id)\n @parent = @car.rides.find(params[:ride_id])\n else\n @parent = @car\n end\n end",
"def has_parent?\n !parent_context.nil?\n end",
"def valid_parent?\n self.class.exists?(self.parent_id.to_i)\n end",
"def parent_name\n parent_info && parent_info.name\n end",
"def parent\n return @parent\n end",
"def parent\n return @parent unless @parent.nil?\n return Message.find(parent_id) unless parent_id.nil?\n end",
"def parent?\n !parent_type.nil?\n end",
"def parent\n self.class.find_in_nested_set(self[parent_col_name]) if self[parent_col_name]\n end",
"def parent_model\n return @parent_model if @parent_model\n\n if parent_model_name && parent_model_class\n parent_id_param = \"#{parent_model_name}_id\"\n if params[parent_id_param]\n @parent_model = parent_model_class.find_by(find_parent_by => params[parent_id_param])\n end\n end\n\n @parent_model\n end",
"def parent\n @parent ||= begin\n parent_id = data[\"parentId\"]\n client.categories.find(parent_id) if parent_id\n end\n end",
"def find_parent_pid pid\n ppid = nil\n wmi.ExecQuery(\"SELECT * FROM Win32_Process WHERE ProcessID=#{pid}\").each{|i|\n ppid = i.ParentProcessID\n }\n return ppid\n end",
"def parent\n return persistence_strategy.parent if\n persistence_strategy.respond_to?(:parent)\n\n nil\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def find_parent_node\n @parent_node ||= Node.find(params[:parent_node_id]) if params[:parent_node_id]\n end",
"def parent_model\n @parent_model ||= (@child_model || Object).find_const(parent_model_name)\n rescue NameError\n raise NameError, \"Cannot find the parent_model #{parent_model_name} for #{child_model_name} in #{name}\"\n end",
"def parent_id\n object[\"parent_id\"]\n end",
"def parent\n SideJob.find(SideJob.redis.get(\"#{redis_key}:parent\"))\n end",
"def existing_parent(dir)\n dir.ascend do |ascendant|\n break ascendant if ascendant.directory?\n end\n end",
"def parent\n folder || @list\n end",
"def parent\n return @links[:parent]\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def get_parent(keyword)\n\n get_parents().each do |findcommand|\n\n if ( findcommand.commandName == keyword)\n return findcommand\n end\n end\n raise(\"#{keyword} parent not defined!\")\n\n end",
"def parent\n @controller.instance_variable_get(:\"@#{parent_name}\")\n end",
"def has_parent!(parent)\n @parent = parent\n self\n end",
"def parent\n if self.rep_parent.nil?\n if self.parent_id.nil?\n return nil\n else\n return Activity.find(self.parent_id)\n end\n\n else\n return self.rep_parent.parent\n end\n end",
"def parent\n @parent ||= @parent_id ? @book.find_account_by_id(@parent_id) : nil\n end",
"def parent\n unless @node.send(@parent).nil?\n @node = @node.send(@parent)\n end\n end",
"def parent_resource\n return @parent_resource if defined?(@parent_resource)\n @parent_resource = if @mediator.through\n if @controller.instance_variable_defined? :\"@#{@mediator.through}\"\n @controller.instance_variable_get(:\"@#{@mediator.through}\")\n elsif @controller.respond_to?(@mediator.through, true)\n @controller.send(@mediator.through)\n end\n end\n end",
"def parent?\n true \n end",
"def parent\n @parent ||= resource.decorate.parent\n end",
"def get_parent_resource\n instance_variable_get(\"@#{parent_resource_name}\")\n end",
"def parent?\n false\n end",
"def get_parent_resource\n parent_id_param = request.path_parameters.keys.detect { |k| k.to_s.end_with?('_id') }\n if parent_id_param\n parent_type = parent_id_param.to_s.chomp('_id')\n parent_class = safe_class_lookup(parent_type.camelize)\n if parent_class\n @parent_resource = parent_class.find(params[parent_id_param])\n end\n end\n end",
"def getParent(child)\n @pmap.keys.each do |c|\n if c.name.name == child\n return @pmap[c].name.name\n end\n end\n return 'Object'\n end",
"def parent_profile\n @parent_profile ||= Profile.where(\"parent_type.email\"=> email).first #if has_role?(:parent)\n end",
"def parent\n @parent or raise LifecycleException.new(\"can't call parent until you materialize the resource\")\n end",
"def parent_list\n self.parent_lists[0]\n end",
"def parent_id\r\n return nil unless ar_object\r\n ar_object[ar_p]\r\n end",
"def children\n @@devices.find {|i, v| i == @id }\n end",
"def parent\n raise \"undefined parent Organization\" unless organization?\n organization\n end",
"def parent\n ltree_scope.find_by \"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)\", ltree_path,\n ltree_path\n end",
"def parent\n _parent\n end"
] |
[
"0.69526756",
"0.6830269",
"0.6823165",
"0.67923945",
"0.6683053",
"0.6677846",
"0.666579",
"0.6550104",
"0.6542374",
"0.64039856",
"0.637274",
"0.6357295",
"0.6278255",
"0.62720096",
"0.62618977",
"0.6219054",
"0.6180903",
"0.6165943",
"0.6160411",
"0.61377126",
"0.612947",
"0.61287326",
"0.6108426",
"0.6104216",
"0.60929346",
"0.609146",
"0.6085046",
"0.60834587",
"0.60832494",
"0.607254",
"0.6069542",
"0.604429",
"0.60435796",
"0.60416484",
"0.6024892",
"0.6023232",
"0.60226566",
"0.60205185",
"0.60193187",
"0.60041994",
"0.5978956",
"0.59779346",
"0.5976895",
"0.5976895",
"0.59429014",
"0.5932207",
"0.59305435",
"0.59298956",
"0.59287244",
"0.59261805",
"0.5914922",
"0.5912853",
"0.5905002",
"0.5900532",
"0.5896216",
"0.5894431",
"0.5890424",
"0.58879215",
"0.58816403",
"0.5876677",
"0.58716136",
"0.58651006",
"0.58625805",
"0.58615595",
"0.58558816",
"0.58406997",
"0.5837927",
"0.5837927",
"0.5837927",
"0.5837927",
"0.58237696",
"0.5822725",
"0.5817141",
"0.58135843",
"0.5810907",
"0.5810305",
"0.5807948",
"0.58072215",
"0.58072215",
"0.58050555",
"0.5800553",
"0.5799465",
"0.57870895",
"0.5785737",
"0.5782331",
"0.5766167",
"0.5757328",
"0.57503796",
"0.57457715",
"0.5740396",
"0.57385975",
"0.5727691",
"0.5717915",
"0.5701282",
"0.56998473",
"0.5692336",
"0.56903094",
"0.56849504",
"0.5683799",
"0.5681253"
] |
0.6999914
|
0
|
Complete the method which accepts an array of integers, and returns one of the following: "yes, ascending" if the numbers in the array are sorted in an ascending order "yes, descending" if the numbers in the array are sorted in a descending order "no" otherwise You can assume the array will always be valid, and there will always be one correct answer.
|
def is_sorted_and_how(numbers)
if numbers.sort == numbers
"yes, ascending"
elsif numbers.sort.reverse == numbers
"yes, descending"
else
"no"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_sorted_and_how(arr)\n if arr == arr.sort \n return 'yes, ascending'\n elsif arr == arr.sort.reverse \n return 'yes, descending' \n else\n return 'no'\n end\nend",
"def is_sorted_and_how(arr)\n arr == arr.sort ? \"yes, ascending\" : arr == arr.sort.reverse ? \"yes, descending\" : \"no\"\nend",
"def is_sorted?(array)\n\n if array.each_cons(2).all? { |a, b| (a <=> b) <= 0 } #comparing a to b. a<b = -1 / a=b = 0. meaning, if ascending.\n return true\n else \n return false\n end\n\nend",
"def sorted?(array) # sorted ascending.\n return true if array.empty?\n return true if array.length == 1\n\n return false if array[0] > array[1]\n\n sorted?(array[1..-1])\nend",
"def isOrdonnedArray(array)\n i = 0\n tmp = 0\n ordonned = true\n\n while ((i < array.length) && ordonned)\n if (i != 0)\n if (tmp < array[i])\n tmp = array[i]\n else ordonned = false\n end\n else tmp = array[i]\n end\n i += 1\n end\n\n if (ordonned)\n puts \"Le tableau est bien ordonné.\"\n else puts \"Le tableau N'est PAS bien ordonné.\"\n end\nend",
"def sorted?(array)\n return true if array.length <= 1\n return false if array[0] > array[1]\n sorted?(array[1..-1])\nend",
"def sorted?(array)\n if array.empty?\n return array\n end\n \n if array.length == 1\n return true\n end\n \n if array[-1] < array[-2]\n return false\n else\n return sorted?(array[0...-1])\n end\n \nend",
"def checksorted(array)\n i = 0\n until i > array.length-2 do\n # print array[i]\n if array[i] > array[i+1] then\n array[i], array[i+1] = array[i+1], array[i]\n print array\n next\n end\n print array\n i +=1\n end\n\n end",
"def is_sorted(array)\n (0...array.length - 1).each { |index| return false if array[index] > array[index + 1] }\n return true\nend",
"def sorted?(arr)\n if arr.length <= 1\n return true\n elsif arr[0] > arr[1]\n return false\n else\n sorted?( arr[1..-1] )\n end\n \nend",
"def sorted?(array)\n if array.length <= 1\n true\n elsif array[0] > array[1]\n false\n else\n sorted?(array.drop(1))\n end\nend",
"def sorted?(array)\n return true if array.length <= 1\n return false unless array[0] <= array[1]\n sorted?(array.drop(1))\nend",
"def sorted?(array)\n return true if array.empty? || array.length == 1\n\n first,second = array[0],array[1]\n\n return false if second < first\n\n sorted?(array[1..-1])\nend",
"def in_order? (array)\n\tif array[i] < array[i+1] \n\t\trun = 0\n\t\trun += 1\n\t\tn +=1\n\tend\nend",
"def check_solution(test_number, array, expected)\n actual = is_sorted?(array)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def check_solution(test_number, array, expected)\n actual = is_sorted?(array)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def is_asc_order(arr) \n ascending = true\n \n arr.each_with_index do |num, index|\n break if index.eql?(arr.length - 1)\n if num > arr[index +1]\n ascending = false\n break\n end\n end\n \n ascending\nend",
"def sorted?(array)\n return true if array.length <= 1\n array[0] > array[1] ? false : sorted?(array.drop(1))\nend",
"def sorted?(array)\n return true if array.count <= 1\n return false if array[0] > array[1]\n sorted?(array.drop(1))\nend",
"def sorted?(array)\n return true if array.length <= 1\n return false if array[0] > array[1]\n sorted?(array.drop(1))\nend",
"def sort_array_desc(array)\n array.sort do |a, b|\n if a == b\n 0\n elsif a > b\n -1\n elsif a < b\n 1\n end\n end\nend",
"def sorted?(arr)\n\nend",
"def sort_array_plus_one(array)\r\n\r\n\tarray.sort! {|x, y| x <=> y}\r\n\tputs \"Input array :\"\r\n\tprint array\r\n\tprint \"\\n\"\r\n\tputs \"Result :\"\r\n\tfor i in array do \r\n\t\tprint i.to_i+1\r\n\t\tprint \", \"\r\n\r\n\tend\r\n\r\nend",
"def sort_array_desc(array)\n array.sort do |a,b|\n if a == b\n 0\n elsif a > b\n -1\n elsif a < b\n 1\n end\n end\nend",
"def sorted?(array)\n num_1 = array.shift\n return true if num_1 == nil\n num_2 = array.first\n return true if num_2 == nil\n return false if (num_1 <=> num_2) == 1\n sorted?(array)\nend",
"def sorted?(array)\n return true if array.length <= 1\n return false if array[0] > array[1]\n sorted?(array.drop(1))\nend",
"def sorted?(array)\n return true if array.length <= 1\n return false if array[0] > array[1]\n sorted?(array.drop(1))\nend",
"def sort_array_desc(array)\n array.sort do |x,y|\n if x == y\n 0\n elsif x < y\n 1\n elsif x > y\n -1\n end\n end\nend",
"def sorted?(array)\n return true if array.length < 2\n return false if array[0] > array[1]\n sorted?(array.drop(1))\nend",
"def is_sorted(arr)\n (0...arr.length - 1).each do |i|\n if arr[i] > arr[i + 1]\n return false\n end\n end\n true\nend",
"def validate?(array)\n \ti = 1\n \tarray.sort!\n \tfor i in array do\n \t\tif(array[i-1] != i) \n \t\t\treturn false\n \t\tend\t\t\n \tend\n\t\treturn true\n end",
"def sorted?(array)\n return [] if array.empty?\n return true if array.length == 1\n return false if array[0] > array[1]\n sorted?(array.drop(1))\nend",
"def is_sorted(arr)\n(0...arr.length-1).all? { |i| arr[i] <= arr[i+1]}\nend",
"def is_sorted(nums)\n # (0...nums.length - 1).each do |i|\n # if nums[i + 1] < nums[i]\n # return false\n # end\n # end\n # true\n# !(0...nums.length - 1).any? {|i| nums[i] > nums[i + 1]}\n (0...nums.length - 1).all? {|i| nums[i] <= nums[i + 1]}\nend",
"def is_sorted(arr)\n (arr[0]...arr.length - 1).each do |i|\n return false if arr[i] > arr[i + 1]\n end\n\n true\nend",
"def establish_high_number(array)\n if array[0] > array[1]\n return array [0]\n else array[0] < array[1]\n return array [1]\n end\nend",
"def sorted?(array)\n return [] if array.empty?\n return true if array.length == 1\n return false if array[0] > array[1]\n dup = array.dup\n dup.shift\n sorted?(dup)\nend",
"def sorted?(array)\n#base case...can pluck values out of array?\n return true if array.size == 1 #true base case\n return false if array == []\n dup_array = array.dup\n if dup_array[0] <= dup_array[1]\n dup_array.shift\n condition = sorted?(dup_array)\n else\n condition = false #stop recursive calls, and also this will never execute if sorted\n end\n condition\nend",
"def descending_order(n)\n arr = n.to_s.split('')\n\n if arr.include?(\"-\")\n puts \"Cannot compute\"\nelse\n arr = arr.sort { |a, b| b <=> a }\n print arr.join(\"\").to_i\n\n\n end\nend",
"def is_sorted?(array)\n\n array2 = []\n array2 = array.dup\n comparison = array2.length - 1\n comparison.times do |end_of_sorted|\n min_value_index = end_of_sorted\n for current_index in (end_of_sorted + 1)..comparison\n min_value_index = end_of_sorted if array[current_index] < array[min_value_index]\n end\n array[end_of_sorted], array[min_value_index] = array[min_value_index], array[end_of_sorted] if min_value_index != end_of_sorted\n end\n \n if array != array2\n return false\n elsif array == array2\n return true\n end\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def sort_array_desc(array)\n array.sort do |a, b|\n b<=>a\n end\nend",
"def iterate_through_array(input_array)\n\n # Initialization of variable used for the checking of the array sorting \n list_is_not_sorted = false\n\n # Duplication of the input array to not destroy the input array\n output_array = input_array\n\n # Loop through a range representing the array indexes\n (0..output_array.length - 2).each do |index|\n\n # Comparison of the two values next to each other and application if the sorting if true\n if (output_array[index] > output_array[index + 1])\n correction_value = output_array[index]\n output_array[index] = output_array[index + 1]\n output_array[index + 1] = correction_value\n\n # If at least one sorting action is processed then another sorting loop needs to be applied\n list_is_not_sorted = true\n end\n end\n\n # Returns a pair with the sorted array in first position and a boolean informing if the array \n # was alrady sorted in second position\n return [output_array, list_is_not_sorted]\nend",
"def sorted?(arr)\n\tfor i in 1...arr.length\n\t\treturn false if arr[i] < arr[i-1]\n\tend\n\n\treturn true\nend",
"def bubble_sort_by(array)\n switch = true\n while switch\n switch = false\n (0...array.length - 1).each do |i|\n if yield(array[i], array[i + 1]).positive? \n array[i], array[i + 1] = array[i + 1], array[i]\n switch = true\n end\n end\n end\n array\nend",
"def check_array(array, num)\n if array.length > 2\n if num < array[0] or num > array[array.length-1]\n return false\n elsif num == array[0] \\\n or num == array[array.length-1] \\\n or num == array[((array.length-1)/2).floor]\n return true\n elsif num < array[((array.length-1)/2).floor]\n return check_array(array[0..((array.length-1)/2).floor-1], num)\n elsif num >= array[((array.length-1)/2).floor]\n return check_array(array[((array.length-1)/2).floor..array.length-1], num)\n end\n else\n return true if num == array[0] or num == array[1]\n return false\n end\nend",
"def is_sorted_asc(a)\n sorted = true;\n # for i in 0..a.size-2 do\n # for-Schleife ist eher albern, wir\n # wollen ja vorzeitig abbrechen, wenn\n # das Array nicht sortiert ist\n i = 0;\n while !sorted && i < a.size-1 do\n if a[i] > a[i+1] then\n sorted = false;\n end;\n i = i+1;\n end;\n return sorted;\nend",
"def orderly(array)\n p array.sort\nend",
"def sort array\n\t\tarray = array.clone\n\t\tfinished = false\n\t\t##\n\t\t# Ok, should be an easy one. Compare the current and next value\n\t\t##\n\t\twhile !finished\n\t\t\t#Flag to track whether an iteration edited the array\n\t\t\twasSorted\t= false\n\t\t\t# Compare value pairs from input array\n\t\t\t(1...array.length).each{|idx|\n\t\t\t\t# Get the target values\n\t\t\t\tcurrentValue\t\t= array[idx]\n\t\t\t\tpreviousValue\t\t= array[idx - 1]\n\t\t\t\t# Figure out if the previous and current value arein the correct order\n\t\t\t\tcurrentVsPrevious\t= @sorter.predict([previousValue, currentValue]).first.round\n\t\t\t\t# If they aren't (as best we know at least), swap the two values\n\t\t\t\tif currentVsPrevious == 0\n\t\t\t\t\tarray[idx]\t\t= previousValue\n\t\t\t\t\tarray[idx - 1]\t= currentValue\n\t\t\t\t\twasSorted\t\t= true\n\t\t\t\tend\n\t\t\t}\n\t\t\t# If no sort action was taken, the array must be sorted.\n\t\t\tfinished = !wasSorted\n\t\tend\n\t\t# Return to caller\n\t\tarray\n\tend",
"def funny_sort(array)\n\tputs array.sort{ |a, b| findEarliestDigits(a) <=> findEarliestDigits(b) }\nend",
"def bubble_sort_by(array)\n (array.length - 1).times do |i|\n \tif yield(array[i], array[i + 1]) < 0\n \t array[i], array[i + 1] = array[i + 1], array[i]\n \tend\n end\n print array\nend",
"def solution(a)\n return 0 if a.length < 3\n a.sort!\n\n for i in 0..(a.length - 3)\n return 1 if a[i] + a[i + 1] > a[i + 2]\n end\n return 0\nend",
"def array_ranked_descending(array)\n\t\treturn array.sort{|x,y| y <=> x} \n\tend",
"def bubbly(arr)\n loop do\n switch = false\n (arr.length - 1).times do |i|\n \tif arr[i] > arr[i + 1]\n arr[i + 1],arr[i] = arr[i],arr[i + 1]\n switch = true\n end\n end\n if switch == false\n break\n end\n end\n arr\nend",
"def sort_array_desc(arr)\n arr.sort{|a,b| b<=>a}\nend",
"def run_pass(input)\n corrections_made = false\n (input.length - 1).times do |index|\n if input[index] > input[index + 1]\n corrections_made = true\n val_0 = input[index +1]\n val_1 = input[index]\n input[index] = val_0\n input[index + 1] = val_1\n end\n end\n return corrections_made\nend",
"def sort(array)\n loop do\n flag = false\n array.each_index do |index|\n break if array[index] == array.last\n if array[index] > array[index + 1]\n array[index], array[index + 1] = array[index + 1], array[index]\n flag = true\n end\n end\n break if flag == false\n end\n return array\n end",
"def bubble_sort(array, &prc)\n\n # Default Proc if none is supplied to sort smallest to lagest.\n prc ||= Proc.new { |a, b| a <=> b }\n\n # Array has default of not being sorted\n sorted = false\n\n # Loop is run unit sorted is true, this happens when the if statement is not entered\n until sorted\n sorted = true\n\n (1...array.length).each do |i|\n\n # Proc is called to check if the two elements in the array are sorted\n if prc.call(array[i - 1], array[i]) == 1\n sorted = false\n array[i - 1], array[i] = array[i], array[i - 1]\n end\n end\n end\n\n array\nend",
"def sort_array_desc(array)\n\tarray.sort do |a, b|\n\t\tb <=> a\n\tend\nend",
"def oky_two_sum?(arr, target)\n sorted = arr.sort\n \nend",
"def sort_array_desc(arry)\n arry.sort do |num1, num2|\n num2 <=> num1\n end\nend",
"def is_valid?(array)\n array.none? {|e| e.zero?} && (array[0] + array[1]) > array[2]\nend",
"def sort_array_desc(array)\n array.sort do |a,b|\n b <=> a\n end\nend",
"def sort_array_desc(array)\n array.sort do |a,b|\n b <=> a\n end\nend",
"def divider sorted_arr, i=0, j=sorted_arr.size-1, left_sum = 0, right_sum = 0\n\n\t\n\treturn 'No' if j<=i\n\t\n\tright_sum += sorted_arr[j]\n\n\twhile left_sum < right_sum\n\t\tleft_sum += sorted_arr[i]\n\t\ti +=1\n\tend\n\tif left_sum == right_sum\n\t\treturn 'Yes' if( sorted_arr[i] == sorted_arr[j-1] || (i == j && sorted_arr[i-1]+1<sorted_arr[j])) \t\n\tend\n\n\tdivider(sorted_arr, i, j-1, left_sum, right_sum)\n\nend",
"def sort_array_desc(array)\n return array.sort{ |a, b| b <=> a }\nend",
"def bubble_sort_by(array)\n\nsorted = false\ncheck_it = array.length - 1 \n\tuntil sorted\n\t\tinorder = true \n\t\tcheck_it.times do |i|\n\t\t\ty = yield(array[i], array[i+1])\n\t\t\tif y == 1 #<=> returns that a > b\n\t\t\t\tarray[i], array[i+1] = array[i+1], array[i] \n\t\t\t\n\t\t\t\tinorder = false \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\n\t\t\tend\n\t\t\n\t\t\tputs array.inspect\t\n\t\t\tend \n\t \t\t\n\t \t\tcheck_it -= 1 \n\t\t\tputs \"end of yield runthrough\" #just to check\n\n\t\t\tif check_it == 0\t\t\t\n\t\t\t\tsorted = true \n\t\t\telsif inorder == true \n\t\t\t\tsorted = true\t\t\n\t\t\n\t\t\tend\n\t\t\n \tend\nend",
"def Superincreasing(arr)\n arr.each_with_index do |num, idx|\n next if idx == 0\n return 'false' unless arr[0...idx].sum < num\n end\n 'true'\nend",
"def bubble_sort_by(array)\n\t#counter\n\titeration = 1\n\t#Loop through all values (array.length-1) times\n\twhile iteration <= array.length-1\n\t\t#Compare 2 adjacent values in array. Values are swapped based on block comparison.\n\t\tarray.each_with_index do |n, i|\n\t\t\tunless array[i+1] == nil #stops comparison of last array value.\n\t\t\t\tif yield(n, array[i+1]) > 0\n\t\t\t\t\tarray[i], array[i+1] = array[i+1], n\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\titeration += 1 # Counter increases after every iteration\n\tend\n\tputs array.inspect\nend",
"def sort_array_desc (integers)\n integers.sort.reverse\nend",
"def solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\nend",
"def is_sorted?(arr)\n temp = arr[0]\n arr.all? { |i| i >= temp && temp = i }\nend",
"def in_order?(arr)\r\n # your code goes here\r\n\r\n arr == arr.sort\r\nend",
"def solve(arr)\n answer = \"Every num has a match.\"\n arr.each do |num|\n if !arr.include?(num * -1)\n answer = num\n end\n end\n answer\nend",
"def manipulating_arrays(array)\n puts array.reverse\n puts array.sort\n return array.sort.reverse\nend",
"def sort_nums_ascending(arr)\n return arr.sort\nend",
"def bubble_sort_by_concept_one(array)\n n = array.length\n\n while n.positive?\n\n j = 0\n\n (1..n - 1).each do |k|\n compare_result = yield array[j], array[k]\n\n # if array[j] > array[k], swap these two values\n if compare_result.positive?\n store = array[j]\n array[j] = array[k]\n array[k] = store\n end\n j += 1\n end\n n -= 1; # last element is now sorted\n end\n\n array\nend",
"def alphabetize(arr, rev=false) # Default value will be false for SECOND\n # parameter if ONLY ONE argument is passed\n arr.sort!\n if rev!=false # Executes line below if TWO arguments are passed (passing TWO\n # arguments will sort the array in DESCENDING order).\n arr.reverse!\n else # Executes line below if ONE argument is passed (passing ONE argument\n # will sort the array in ASCENDING order)\n arr.sort!\n end\nend",
"def check_list(array)\n min = array.first\n i = 0\n while i < array.length\n j = i + 1\n while j < array.length\n min = array[i] if array[i] < array[j] && array[i] < min\n j += 1\n end\n i += 1\n end\n min\n end",
"def correct?\n inorder.each_cons(2).all? { |p, n| p <= n }\n end",
"def bubble_sort_by(array)\n arr = array.length - 1\n loop do\n swap = false\n (0...arr).each do |i|\n n_one = array[i]\n n_two = array[i + 1]\n if yield(n_one, n_two).positive?\n array[i], array[i + 1] = array[i + 1], array[i]\n swap = true\n end\n end\n break if swap == false\n end\n array\nend",
"def sort_array_desc(array)\n array.sort do | left, right|\n right <=> left\n end\nend",
"def is_sorted(input)\n if (input.length < 2)\n return true\n end\n for i in 1..input.length - 1\n if (input[i-1] > input[i])\n return false\n end\n end\n return true\nend",
"def is_sorted(input)\n if (input.length < 2)\n return true\n end\n for i in 1..input.length - 1\n if (input[i-1] > input[i])\n return false\n end\n end\n return true\nend",
"def is_sorted(input)\n if (input.length < 2)\n return true\n end\n for i in 1..input.length - 1\n if (input[i-1] > input[i])\n return false\n end\n end\n return true\nend",
"def is_sorted(input)\n if (input.length < 2)\n return true\n end\n for i in 1..input.length - 1\n if (input[i-1] > input[i])\n return false\n end\n end\n return true\nend",
"def is_sorted(input)\n if (input.length < 2)\n return true\n end\n for i in 1..input.length - 1\n if (input[i-1] > input[i])\n return false\n end\n end\n return true\nend",
"def alphabetize(arr, rev=false)\n if rev == false\n arr.reverse! #this method doesn't default to alphabetizing an array when\n #it doesn't receive a second parameter.\n else\n arr.sort!\n end\nend",
"def sort_array_desc(array)\n desc_array = array.sort {|a, b| b <=> a}\n desc_array\nend",
"def sort_array_desc(integers)\n integers.sort.reverse\nend",
"def sort_array_desc(integers)\n integers.sort.reverse\nend",
"def sort_array_desc(array)\n array.sort {|a,b| b <=> a}\nend",
"def nyc_bribes(a)\n return -1 unless is_valid?(a)\np \"valid\"\n k = bubble_sort(a)\n\n return k\nend",
"def sorting(arr)\n#display orig array\n p arr \n p \"**************************************************\"\n # do something to the array\n # compare each value of an array to the value on its left\n # if the value is less than the value on its left, switch places\n # do this by placing the lesser value in a holder and then moving the greater\n # value to the lesser value's former position in the array, then rewrite the\n # greater value's former position, with the holder value.\n # do this until the value is greater than the value on its left for \n # the entire array \n#Here is our brute force attempt at making our own .sort! method\n#we used the .sort! method from the Array class.\narr.length.times do\n |x|\n holder = \"\"\n if arr[x] > arr[x-1]\n holder = arr[x-1]\n arr[x-1] = arr[x]\n arr[x] = holder\n end \n end\nputs \"this is the one we made #{arr} \"\n # if arr[1] > arr[0]\n p arr.sort!\n p \"above is the sorting method\"\n#rerturn the changed array\nend",
"def sort_array_desc(array)\n array.sort {|x,y| y <=> x}\nend",
"def check(arr)\n sort_array = arr.sort\n puts \"sort_array = #{sort_array}\"\n puts \"--------------------\"\n puts \"-------arr= #{arr}\"\n\n return \"NO\" if arr == sort_array #retorne NO quando arr == s\n arr.length.times do\n puts \"arr.rotate! #{arr.rotate!}\"\n return \"YES\" if arr == sort_array\n end\n \"NO\"\nend",
"def solution(nums)\n nums.to_a.sort\nend",
"def my_min_2(array)\n array.sort!\n array.first\nend",
"def positive_dominant(arr)\n #Your code here\n arr_uniq = arr.uniq\n pos_arr = []\n neg_arr = []\n arr_uniq.map do |x|\n if x > 0\n pos_arr.push(x)\n else\n neg_arr.push(x)\n end\n end\n\n if pos_arr.length > neg_arr.length\n return true\n else\n return false\n end\n\nend",
"def in_order?(arr)\n arr == arr.sort\n # your code goes here\nend"
] |
[
"0.7304954",
"0.71570307",
"0.6782844",
"0.65234137",
"0.6510752",
"0.65092766",
"0.64166933",
"0.6411729",
"0.6399094",
"0.6358728",
"0.63401425",
"0.63190717",
"0.6258218",
"0.6256327",
"0.6219555",
"0.6219555",
"0.6194703",
"0.61894",
"0.61864525",
"0.6185327",
"0.6181142",
"0.61766917",
"0.61673766",
"0.61640453",
"0.6150255",
"0.61450243",
"0.61450243",
"0.6120535",
"0.61159366",
"0.6115752",
"0.6114359",
"0.61110616",
"0.6101586",
"0.60411954",
"0.6040744",
"0.6027606",
"0.60179293",
"0.59894216",
"0.59820086",
"0.5950797",
"0.5935243",
"0.59299123",
"0.59258723",
"0.5903679",
"0.58736414",
"0.5845939",
"0.5797284",
"0.57841814",
"0.5771032",
"0.576371",
"0.57571656",
"0.575557",
"0.5755139",
"0.57503176",
"0.57390714",
"0.5738093",
"0.5728344",
"0.5728156",
"0.5709646",
"0.57089293",
"0.5687699",
"0.56761324",
"0.5674878",
"0.5674878",
"0.5674411",
"0.5670388",
"0.5664699",
"0.5651918",
"0.564792",
"0.56472117",
"0.56414413",
"0.5639908",
"0.5637165",
"0.56363755",
"0.56350124",
"0.5623242",
"0.562217",
"0.5620209",
"0.56184995",
"0.56173044",
"0.5608058",
"0.5603073",
"0.55978215",
"0.55978215",
"0.55978215",
"0.55978215",
"0.55978215",
"0.5597057",
"0.5586971",
"0.55839354",
"0.55833656",
"0.5576005",
"0.5573174",
"0.5570496",
"0.55690145",
"0.5568689",
"0.55667603",
"0.5557757",
"0.555311",
"0.5552679"
] |
0.6843163
|
2
|
human readable description of modeling approach
|
def modeler_description
return "Purging objects like space types, schedules, and constructions requires a specific sequence to be most effective. This measure will first remove unused space types, then load defs, schedules sets, schedules, construction sets, constructions, and then materials. A space type having a construction set assign, will show that construction set as used even if no spaces are assigned to that space type. That is why order is important."
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end",
"def modeler_description\n return \"Example use case is adding special loads like an elevator to a model as part of an analysis workflow\"\n end",
"def modeler_description\n return 'Currently this is just setup for design level calculation method, but it could be extended as needed..'\n end",
"def modeler_description\n return 'shift or/and adjust heaing and cooling setpoint'\n end",
"def modeler_description\n return 'This model replaces the existing HVAC system with a VRF + DOAS system.'\n end",
"def modeler_description\n return \"This uses the OpenStudio::Model::Space::fromFloorPrint method, and is very much like the Create Spaaces From Diagram tool in the OpenStudio SketchUp plugin, but lets you draw teh diagram in the tool of your choice, and then imports it into the OpenStudio application via a measure.\"\n end",
"def modeler_description\n return 'This can be used in apply measure now, or can be used in a parametric workflow to load in any custom user profiles or floor/ceiling values.'\n end",
"def modeler_description\r\n return \"objective function\"\r\n end",
"def modeler_description\r\n return \"objective function\"\r\n end",
"def modeler_description\n return \"Any generators and electric load center distribution objects are removed. An electric load center distribution object is added with a track schedule equal to the hourly output from SAM. A micro turbine generator object is add to the electric load center distribution object. The fuel used to make the electricity is zeroed out.\"\n end",
"def modeler_description\r\n return \"For each model, find every DX cooling and heating coil and increase the COP to 6. Since very little information about this technology is available, do not change performance curves or upper/lower operating temperature limits.\"\r\n end",
"def modeler_description\n return 'Modify the cooling setpoint of the HVAC system during a DR event'\n end",
"def modeler_description\n return 'This a test measure in relation with https://github.com/NREL/OpenStudio/issues/4156'\n end",
"def modeler_description\n return \"When have existing OSM wanted to be able to grab geometry from model vs. trying to enter on website. This is useful when there is no built structures yet to use as reference on the website.\"\n end",
"def modeler_description\n return \"Grey water tank overflow will be dirrected to drainage. \"\n end",
"def modeler_description\n return \"NOTE: This will load and respond slowly in the OS app, especially if you select * on a variable with many possible keys or you select timestep data. Suggest you open it in a web browser like Chrome instead.\"\n end",
"def modeler_description\n return 'HVAC system creation logic uses [openstudio-standards](https://github.com/NREL/openstudio-standards) and efficiency values are defined in the openstudio-standards Standards spreadsheet under the *NREL ZNE Ready 2017* template.'\n end",
"def description()\n\t\tself.namespaced_class(:ModelDescriptor).goal(self)\n\tend",
"def modeler_description\n 'NOTE: This will load and respond slowly in the OS app, especially if you select * on a variable with many possible keys or you select timestep data. Suggest you open it in a web browser like Chrome instead.'\n end",
"def modeler_description\n return 'Not sure how I will handle arguments. Maybe lump together all spaces on same sotry that have the same multilier value. This will have variable number of arguments basd on the model pased in. Alternative is to either only allo w one group to be chosen at at time, or allow a comlex string that describes everything. Also need to see how to define shirting. There is an offset but it may be above and below and may not be equal. In Some cases a mid floor is halfway betwen floors which makes just copying the base surfaces as shading multiple times probemeatic, since there is overlap. It coudl be nice to stretch one surface over many stories. If I check for vertial adn orthogonal surface that may work fine. '\n end",
"def modeler_description\n return \"It does not even send anything related to the model. It just sends a simple pagkage at the end of every run, just to test if things really work.\"\n end",
"def modeler_description\n return ['Adds', 'the', 'properties', 'for', 'the', 'MoisturePenetrationDepthConductionTransferFunction', 'or', 'effective', 'moisture', 'penetration', 'depth', '(EMPD)', 'Heat', 'Balance', 'Model', 'with', 'inputs', 'for', 'penetration', 'depths.', \"\\n\\n\", 'Leaving', 'Change', 'heat', 'balance', 'algorithm?', 'blank', 'will', 'use', 'the', 'current', 'OpenStudio', 'heat', 'balance', 'algorithm', 'setting.', \"\\n\\n\", 'At', 'least', '1', 'interior', 'material', 'needs', 'to', 'have', 'moisture', 'penetration', 'depth', 'properties', 'set', 'to', 'use', 'the', 'EMPD', 'heat', 'balance', 'algorithm.'].join(' ')\n end",
"def modeler_description\n return \"Change water heater efficiency and fuel type.\"\n end",
"def modeler_description\n return \"Assume that the starting point technology is primarily 90.1-2013 T8 lighting, with an efficacy of 90 lm/W. According to Table 5.2, LED Efficacy Improvement, in (1), 2015 LED luminaire efficacy is 145 lm/W. Calculate the total lighting power of the model and divide by this initial efficacy to determine the total number of lumens needed. Assuming that this same number of lumens should be provided by LED lighting, divide by the LED efficacy to determine the total wattage of LEDs that would be necessary to achieve the same lighting. Reduce the overall building lighting power by the resulting multiplier. IE new LPD = old LPD * (1 - 90 lm/W /145 lm/W). This is a very crude estimate of the impact of current LED technology. In order to perform a more nuanced analysis, lighting in the prototype buildings should be broken down by use type (general space lighting, task lighting, etc.) and by currently assumed technology (T12, T8, metal halide, etc.). If this breakdown were available, each type of lighting could be modified according to its own efficacy characteristics. Additionally, this measure does not account for the impact of LEDs on outdoor lighting.\"\n end",
"def modeler_description\n return 'For each model, find every DX cooling and heating coil and increase the COP to 6. Since very little information about this technology is available, do not change performance curves or upper/lower operating temperature limits.'\n end",
"def modeler_description\n return \"This measure will replicate the functionality described in the EnergyPlus Energy Management System Application Guide, Example 2., based on user input.\"\n end",
"def modeler_description\n return 'This measure assigns load and flow information to a selected plant loop load profile.'\n end",
"def modeler_description\n return \"This is intended to run on an empty model. It will create the proper model associate it with the proper weather file, and add in necessary output requests. Internally to the measure the test case argument will be mapped to the proper inputs needed to assemble the model. The measure will make some objects on the fly, other objects will be pulled from existing data resources. This measure creates cases described all of section 5.3.\"\n end",
"def modeler_description\n return \"Each DX cooling coil in the model is replaced by a membrane heat pump. To represent the membrane heat pump, the DX cooling coil COP is increased to 7.62 (26 EER). Additionally, add a water use equipment object to account for the 3 gallons of water used per ton*hr of sensible cooling process.\"\n end",
"def modeler_description\n 'For the most part consumption data comes from the tabular EnergyPlus results, however there are a few requests added for time series results. Space type and loop details come from the OpenStudio model. The code for this is modular, making it easy to use as a template for your own custom reports. The structure of the report uses bootstrap, and the graphs use dimple js.'\n end",
"def modeler_description\n return 'Adds typical refrigeration equipment to a building'\n end",
"def modeler_description\r\n return \"\"\r\n end",
"def modeler_description\n return \"E+ RESNET\"\n end",
"def modeler_description\n return \"Reads the model and sql file to pull out the necessary information and run the model checks. The check results show up as warning messages in the measure's output on the PAT run tab.\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"A measure that will take Annual Building Utilty Performance tables, Demand End use Components summary table, Source Energy End Use Components Summary and produce an output Json\"\n end",
"def modeler_description\n return \"Reads the model and sql file to pull out the necessary information and run the model checks. The check results show up as Warning messages in the measure's output on the PAT run tab.\"\n end",
"def modeler_description\n return 'The goal of this measure is to create a single space type that represents the loads and schedules of a collection of space types in a model. When possible the measure will create mulitple load instances of a specific type in the resulting blended space type. This allows the original schedules to be used, and can allow for down stream EE measures on specific internal loads. Design Ventilation Outdoor Air objects will have to be merged into a single object. Will try to maintain the load design type (power, per area, per person) when possible. Need to account for zone multipliers when createding blended internal loads. Also address what happens to daylighting control objets. Original space types will be left in the model, some may still be assigned to spaces not included in the building area.'\n end",
"def modeler_description\n 'It will be used for calibration maximum flow rate, efficiency, pressure rise and motor efficiency. User can choose between a SINGLE Fan or ALL the Fans.'\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return ''\n end",
"def modeler_description\n return 'This measure has optional arguments to apply recommendations from different sections of the Zero Energy Multifamily Design Guide.'\n end",
"def modeler_description\n 'It will be used for calibration of WaterHeaterMixed. User can choose between a SINGLE WaterHeaterMixed or ALL the WaterHeaterMixed objects.'\n end",
"def modeler_description\n return \"It will be used for calibration of inlet water temperatures, inlet and outlet air temperatures and design flowrates. User can choose between a SINGLE coil or ALL the Coils.\"\n end",
"def modeler_description\n return 'Find the exterior lighting template for the building, and assume the existing efficiency level in the model (low, medium, high). Find the desing level and multiplier for each category of the exterior lighting definition. Apply the lighting upgrades by reducing the design level associated with each outdoor lighting category by a percent (depends on starting and target efficiency levels).'\n end",
"def modeler_description\n return 'Change UrbanOpt Scenario CSV'\n end",
"def modeler_description\n return 'Calculate thermal capacitance and UA for surfaces, furniture, and spaces.'\n end",
"def modeler_description\n return 'Reports resilience metric(s) of interest.'\n end",
"def modeler_description\n return \"The default space types in the measure inputs are automatically filled by the spaces' standard space types. User can overwrite the default assumptions in the library.csv file in the measure's resources folder.\"\n end",
"def modeler_description\n return 'Find the interior lighting template for the building, and assume the existing efficiency level in the model (low, medium, high, very high). Find the LPD and LPD fractions for each space type. Apply the lighting upgrades by reducing the LPD associated with compact lighting by a percent (depends on starting and target efficiency levels).'\n end",
"def modeler_description\n 'Run a simulation to autosize HVAC equipment and then apply these autosized values back to the model.'\n end",
"def modeler_description\r\n return \"E+ measure to popolate the Kiva settings values\"\r\n end",
"def modeler_description\n return 'This method calculates the annualized coefficient of performance (Btu out / Btu in) of equipment in the model from the annual simulation. This is used in Scout as the equipment efficiency for the technology competition categories.'\n end",
"def modeler_description\n return 'This will only impact schedule rulesets. It will use methods in openstudio-standards to infer hours of operation, develop a parametric formula for all of the ruleset schedules, alter the hours of operation inputs to that formula and then re-apply the schedules. Input is expose to set ramp frequency of the resulting schedules. If inputs are such that no changes are requested, bypass the measure with NA so that it will not be parameterized. An advanced option for this measure would be bool to use hours of operation from OSM schedule ruleset hours of operation instead of inferring from standards. This should allow different parts of the building to have different hours of operation in the seed model.'\n end",
"def modeler_description\n return \"Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.\"\n end",
"def modeler_description\n return \"Any supply components or baseboard convective electrics/waters are removed from any existing air/plant loops or zones. Any existing air/plant loops are also removed. A heating DX coil, cooling DX coil, electric supplemental heating coil, and an on/off supply fan are added to a unitary air loop. The unitary air loop is added to the supply inlet node of the air loop. This air loop is added to a branch for the living zone. A diffuser is added to the branch for the living zone as well as for the finished basement if it exists.\"\n end",
"def modeler_description\r\n return 'modify simulation timestep'\r\n end",
"def modeler_description\n return 'Will add the necessary UtilityCost objects and associated schedule into the model.'\n end",
"def modeler_description\n return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.'\n end",
"def modeler_description\n return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.'\n end",
"def modeler_description\n return 'Passes in all arguments from the options lookup, processes them, and then registers values to the runner to be used by other measures.'\n end",
"def modeler_description\n return 'Daylighting controls will physically add in daylighting controls to spaces in the building, while occupancy control will reduce lighting schedules by 10%.'\n end",
"def modeler_description\n return 'This measure is used to calibrate the BRICR baseline model.'\n end",
"def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to model the performance of HVAC equipment that cannot be represented well by using single “standard” performance curve objects (cubic, quadratic, biquadratic, etc.) For example, properly characterizing some HVAC equipment objects requires using different performance curves that cover operation of different parts of the performance regime. This measure will alter (overwrite) the Coil Cooling DX Single Speed Cooling Capacity as a function of temperature performance curve object and attributes used by the simulation if the outdoor air temperature falls below a user defined threshold. This measure allows the user to define the biquadratic curve coefficients associated with the Coil Cooling DX Single Speed Cooling Capacity.\"\n end",
"def modeler_description\n return \"This EEM adds EMS logic to the model that actuates the infiltration, HVAC operation, cooling set point, and heating set point schedules. The measure first identifies the schedule HVAC stopping point by day of week (Saturday, Sunday, and Weekdays). Early HVAC system shutoff is determined entirely by the outdoor air temperature (OAT). If the OAT is less than or equal to 2C or greater than or equal to 18C, then no action is taken. The HVAC system is shut off one hour early when the OAT is between 12C and 18C. The HVAC system shut off time varies linearly with OAT from one hour to zero hours between 12C and 2C, and between 18C and 28C. AvailabilityManager:OptimumStart objects are inserted for each HVAC system in the model and use the AdaptiveASHRAE algorithm to dynamically adjust HVAC startup time each day.\"\n end",
"def modeler_description\n return \"Multipliers for LPD, EPD, and people densities.\"\n end",
"def modeler_description\n return \"This measure takes the user selected standards space type and sets the interior lighting and equipment load definitions subcategory to match the space type name. \"\n end",
"def modeler_description\n return 'Will add the necessary UtilityCost objects into the model.'\n end",
"def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to override specified thermostat control logic and set alternate modes of operation. This EMS measure sets a specific (user defined) indoor VRF terminal unit to operate at a specific (user-defined) part load ratio, constrained by operate minimum and maximum outdoor temperature limits of the paired condenser unit. The main input objects that implement this example are the variable refrigerant flow actuators that control the VRF system and specific terminal unit. Note that the terminal unit PLR can be controlled without controlling the mode of the VRF condenser, however, the specific terminal unit will operate in whatever mode the existing operation control scheme chooses. This example program simply “sets” the operating mode and PLR, other more complex control algorithms can be developed by the user as needed\"\n end",
"def modeler_description\n return 'This measure swaps old cases with 2017 code compliant cases and more efficient ones.'\n end",
"def modeler_description\n return \"The example demonstrates the use of a thermostat schedule object as and EMS actuator object. The EMS program alters the scheduled values as a function of hour of day and day of week.\"\n end",
"def modeler_description\n 'This measure changes the Layer 0 properties of Thickness, Density, Thermal Absorptance, Solar Absorptance, Visible Absoptance, Thermal Conductivity, Specific Heat.'\n end",
"def modeler_description\n return \"The measure loops through the AirLoops associated with the model, and determines an occupancy weighted schedule with values of 1 or 0 based on the percent of peak occupancy at the timestep being above or below a set threshold value of 5 percent. The resulting occupancy schedule is applied to the airloop attribute for the availability schedule. The measure then loops through all thermal zones, examining if there are zone equipment objects attached. If there are one or more zone equipment object attached to the zone, a thermal zone occupancy weighted schedule with values of 1 or 0 based on the percent of peak occupancy at the timestep being above or below a set threshold value of 5 percent is generated. The schedule is then assigned to the availability schedule of the associated zone equipment. To prevent energy use by any corresponding plant loops, the pump control type attribute of Constant or Variable speed pump objects in the model are set to intermittent. The measure them adds heating and cooling unmet hours and Simplified ASHRAE Standard 55 warning reporting variable to each thermal zone. \"\n end",
"def modeler_description\r\n return \"This measure loops through the existing airloops, looking for loops that have a constant speed fan. (Note that if an object such as an AirloopHVAC:UnitarySystem is present in the model, that the measure will NOT identify that loop as either constant- or variable-speed, since the fan is located inside the UnitarySystem object.) The user can designate which constant-speed airloop they'd like to apply the measure to, or opt to apply the measure to all airloops. The measure then replaces the supply components on the airloop with an AirloopHVAC:UnitarySystem object. Any DX coils added to the UnitarySystem object are of the type CoilCoolingDXMultiSpeed / CoilHeatingDXMultiSpeed, with the number of stages set to either two or four, depending on user input. If the user opts for a gas furnace, an 80% efficient CoilHeatingGas object is added. Fan properties (pressure rise and total efficiency) are transferred automatically from the existing (but deleted) constant speed fan to the new variable-speed fan. Currently, this measure is only applicable to the Standalone Retail DOE Prototype building model, but it has been structured to facilitate expansion to other models with a minimum of effort.\"\r\n end",
"def modeler_description\n return \"The measure loops through the heating and cooling thermostat schedules associated each thermal zone. The existing heating and cooling schedules are cloned, and the all run period profiles are then modified by adding a +1.5 deg F shift to the all values of the cooling thermostat schedule and a -1.5 degree F shift to all values of the heating thermostat schedule. Design Day profiles are not modified. The modified thermostat schedules are then assigned to the thermal zone. For each Thermal Zone, ASHRAE 55 Thermal Comfort Warnings is also enabled. Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status output variables is also added to the model.\"\n end",
"def modeler_description\r\n return \"The Measure adds a Schedule Availability Manager to the Selected Plant Loop\"\r\n end",
"def modeler_description\n return 'Converts the OpenStudio model to vA3C JSON format and renders using Three.js, simulation data is applied to surfaces of the model'\n end",
"def modeler_description\n return 'This energy efficiency measure (EEM) replaces all cooling tower objects in a model of the following types: (OS:CoolingTowerPerformanceCoolTools, OS:CoolingTowerPerformanceYorkCalc, OS:CoolingTowerSingleSpeed, OS:CoolingTowerTwoSpeed, or OS:CoolingTowerVariableSpeed) with a new OS:CoolingTower:VariableSpeed object. If an existing cooling tower is already configured for variable speed, the measure will inform the user. When replacing an existing tower object, the following values from the existing tower configuration will be reused: Design Inlet Air Wet Bulb Temp, Design Approach Temperature, Design Range Temperature, Design Water Flow Rate, Design Air Flow Rate, Design Fan Power, Fraction of Tower Capacity in the Free Convection Regime, Basin Heater Capacity, Basin Heater Setpoint Temperature, Basin Heater Operating Schedule, Number of Cells, Cell Control, Cell Minimum and Maximum Water Flow Rate Fractions and Sizing Factor. A performance curve relating fan power to tower airflow rates is used. The curve assumes the fan power ratio is directly proportional to the air flow rate ratio cubed. A Minimum Air Flow Rate Ratio of 20% will be set. To model minimal but realistic water consumption, the Evaporation Loss Mode for new Tower objects will be set to ?Saturated Exit? and Drift Loss Percent will be set to a value of 0.05% of the Design Water Flow. Blowdown water usage will be based on maintaining a Concentration Ratio of 3.0.'\n end",
"def make_and_model; end",
"def modeler_description\n return 'Replaces exterior window constructions with a different construction from the model.'\n end",
"def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to investigate dynamic envelope technologies such as emulating thermochromic window performance using EMS actuators and control types. This measure will replace the construction description of a user-selected window based on the outside surface temperature of that window, evaluated at each timestep\"\n end",
"def modeler_description\n return \"This measure will demonstrate how EMS functions can be used to demonstrate how information from a sizing run can be used to select HVAC equipment from nominal product sizes where unit total capacity is directly related to the unit supply airflow (1 ton = 1200 cfm, 1.5 ton = 1600 cfm, etc.) of commercial packaged single-zone HVAC air systems. This measure is designed to work on AirLoops with packaged DX cooling equipment only. EMS functions will be used to extract the design supply airflow generated from system auto-sizing calculations. An interval variable is used to override the Sizing:System - 'Intermediate Air System Main Supply Volume Flow Rate' value variable. This measure approximates the manner that appropriate ‘real world’ equipment selections are made by HVAC design engineers. The table below will be used to map to the Maximum Flow rate of the packaged unit Fan:ConstantVolume object.\"\n end",
"def modeler_description\n return \"This measure adds active or passive chilled beam units to selected conditioned thermal zones. In addition the user can select an existing air loop to serve active beams, or create a new Dual Wheel DOAS. Users can also select an existing chilled water loop to provide chilled water to beams, or create a new high temperature chiller water loop. Users are highly encouraged to review and modify the control strategies that this measure creates, such that it reflects their modeling scenario of interest.\"\n end",
"def modeler_description\n return \"The difference between actual spaces and effective spaces takes into account the zone multipliers. The goal was to get average floor area assuming that each space represents a room vs. a collection of rooms. This was used to help determine average space sizes of different space types from the prototype buildings. In some cases I had to manaually adjust for where a space didn't map to a single room.\"\n end",
"def modeler_description\n return \"Any heating components or baseboard convective electrics/waters are removed from any existing air/plant loops or zones. A boiler along with constant speed pump and water baseboard coils are added to a hot water plant loop.\"\n end",
"def modeler_description\n return 'Thermal zones will be named after the spac with a prefix added'\n end",
"def inspect\n \"#<#{self.class.name} @model=#{model.name} @relation_name=#{relation_name} @repository=#{self.class.repository}>\"\n end",
"def inspect\n \"#<#{self.class.name} @model=#{model.inspect} @name=#{name.inspect}>\"\n end",
"def modeler_description\n return \"Reduces runtime fraction of lights by user-specified amount during the user-specified time period (typically daytime). This is an attempt to represent the impact of using the light collected on the roof instead of electric lighting. This modeling approach does not capture the impact of using a PV cell to turn the IR spectrum of the captured light into electricity.\"\n end",
"def modeler_description\n return 'This measure receives the AntiSweat heater Control from the user. Then it looks for refrigerated display cases; it loops through them; it checks the current AntiSweat heater Control of each case and it substitute it with the one chosen by the user.'\n end"
] |
[
"0.7710149",
"0.76145315",
"0.75934714",
"0.74018747",
"0.7299891",
"0.7296635",
"0.727943",
"0.71912926",
"0.71912926",
"0.7191264",
"0.7100944",
"0.70977926",
"0.70629936",
"0.7045383",
"0.7044268",
"0.70413125",
"0.7040473",
"0.7032938",
"0.70267737",
"0.70182866",
"0.69875926",
"0.6980763",
"0.69496983",
"0.69420075",
"0.6936087",
"0.6927004",
"0.6908837",
"0.6901907",
"0.6893215",
"0.6888214",
"0.68663764",
"0.6865241",
"0.68641704",
"0.68588334",
"0.6852012",
"0.6852012",
"0.6852012",
"0.6852012",
"0.6852012",
"0.6852012",
"0.6852012",
"0.6833133",
"0.68219167",
"0.68055475",
"0.6791062",
"0.67879057",
"0.67879057",
"0.67879057",
"0.67879057",
"0.67879057",
"0.67879057",
"0.67879057",
"0.67796487",
"0.6773994",
"0.6751447",
"0.67244256",
"0.6720888",
"0.6716974",
"0.6708703",
"0.67021894",
"0.668961",
"0.66878057",
"0.6672712",
"0.6662903",
"0.6649447",
"0.6643762",
"0.6634445",
"0.66330194",
"0.662195",
"0.6616422",
"0.6616422",
"0.66100585",
"0.659982",
"0.6589568",
"0.6588373",
"0.65865505",
"0.6584234",
"0.65638506",
"0.6560483",
"0.6554784",
"0.65097153",
"0.64903986",
"0.64771026",
"0.6466807",
"0.6462787",
"0.6450267",
"0.6443914",
"0.64391804",
"0.6431919",
"0.6429849",
"0.6426015",
"0.6422519",
"0.6421918",
"0.64181775",
"0.6415888",
"0.6409096",
"0.64074343",
"0.64067763",
"0.6405944",
"0.64003026",
"0.6370144"
] |
0.0
|
-1
|
define the arguments that the user will input
|
def arguments(model)
args = OpenStudio::Ruleset::OSArgumentVector.new
# bool to remove unused remove_unused_space_types
remove_unused_space_types = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_space_types",true)
remove_unused_space_types.setDisplayName("Remove Unused Space Types")
remove_unused_space_types.setDefaultValue(false)
args << remove_unused_space_types
# bool to remove unused remove_unused_load_defs
remove_unused_load_defs = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_load_defs",true)
remove_unused_load_defs.setDisplayName("Remove Unused Load Definitions")
remove_unused_load_defs.setDefaultValue(false)
args << remove_unused_load_defs
# bool to remove unused remove_unused_schedules
remove_unused_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_schedules",true)
remove_unused_schedules.setDisplayName("Remove Unused Schedules Sets and Schedules")
remove_unused_schedules.setDefaultValue(false)
args << remove_unused_schedules
# bool to remove unused constructions
remove_unused_constructions = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_constructions",true)
remove_unused_constructions.setDisplayName("Remove Unused Construction Sets, Constructions, and Materials")
remove_unused_constructions.setDefaultValue(false)
args << remove_unused_constructions
return args
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def arguments\n \"\"\n end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def get_input \n puts \"to save this game, input 's,filename'\"\n puts \"to load a game, input 'l,filename'\"\n puts \"input a coordinate to access. prefix with r for reveal or f for flag\"\n puts \"example 'f,1,2' places a flag at 1,2\"\n input = gets.chomp\n \n args = input.split(',')\n end",
"def args(*) end",
"def arguments(required, *optional)\n puts \"required: #{required}\"\n puts \"optional: #{optional}\"\nend",
"def args()\n #This is a stub, used for indexing\n end",
"def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for the variable name\n variable_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"variable_name\",true)\n variable_name.setDisplayName(\"Enter Variable Name.\")\n variable_name.setDescription(\"Valid values can be found in the eplusout.rdd file after a simulation is run.\")\n args << variable_name\n \n #make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Zone Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency.\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n\n #make an argument for the key_value\n key_value = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"key_value\",true)\n key_value.setDisplayName(\"Enter Key Name.\")\n key_value.setDescription(\"Enter * for all objects or the full name of a specific object to.\")\n key_value.setDefaultValue(\"*\")\n args << key_value\n \n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\n env.setDisplayName(\"availableEnvPeriods\")\n env.setDescription(\"availableEnvPeriods\")\n env.setDefaultValue(\"RUN PERIOD 1\")\n args << env\n \n return args\n end",
"def set_arguments (args)\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for the variable name\n variable_name = OpenStudio::Measure::OSArgument.makeStringArgument('variable_name', true)\n variable_name.setDisplayName('Enter Variable Name.')\n variable_name.setDescription('Valid values can be found in the eplusout.rdd file after a simulation is run.')\n args << variable_name\n\n # make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency.')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n # make an argument for the key_value\n key_value = OpenStudio::Measure::OSArgument.makeStringArgument('key_value', true)\n key_value.setDisplayName('Enter Key Name.')\n key_value.setDescription('Enter * for all objects or the full name of a specific object to.')\n key_value.setDefaultValue('*')\n args << key_value\n\n env = OpenStudio::Measure::OSArgument.makeStringArgument('env', true)\n env.setDisplayName('availableEnvPeriods')\n env.setDescription('availableEnvPeriods')\n env.setDefaultValue('RUN PERIOD 1')\n args << env\n\n args\n end",
"def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end",
"def arguments=(_arg0); end",
"def command_line\r\n ARGV.each do |arg|\r\n if arg == \"instructions\"\r\n instructions\r\n elsif arg == \"calculator\"\r\n ask_for_digits\r\n else\r\n \r\n end\r\n end\r\n \r\n end",
"def prescreen_input(args)\n if ((args.nil?) || (args.empty?))\n ['-eq', Date.today.strftime('%Y-%m-%d')]\n elsif ((args.length == 1) && (args[0].is_date?))\n ['-eq', args[0]]\n else\n args\n end\nend",
"def varios_args(*args)\n puts \"Tamanho de args: #{args.size}\"\n args.each { |x| p x}\n end",
"def process_arguments\n @e_addr = @options.email\n @r_name = @options.run_names\n @m_name = @options.machine_names\n @action = @options.action\n @snfs = @options.snfs\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # url of the city database\n city_db_url = OpenStudio::Measure::OSArgument.makeStringArgument('city_db_url', true)\n city_db_url.setDisplayName('City Database Url')\n city_db_url.setDescription('Url of the City Database')\n city_db_url.setDefaultValue('')\n args << city_db_url\n\n # project id to update\n project_id = OpenStudio::Measure::OSArgument.makeStringArgument('project_id', true)\n project_id.setDisplayName('Project ID')\n project_id.setDescription('Project ID to generate reports for.')\n project_id.setDefaultValue('0')\n args << project_id\n\n # datapoint id to update\n datapoint_id = OpenStudio::Measure::OSArgument.makeStringArgument('datapoint_id', true)\n datapoint_id.setDisplayName('Datapoint ID')\n datapoint_id.setDescription('Datapoint ID to generate reports for.')\n datapoint_id.setDefaultValue('0')\n args << datapoint_id\n\n return args\n end",
"def validate_args (args)\n\t# todo\nend",
"def args() return @args end",
"def input=(_arg0); end",
"def process_inputs(args)\n @input = ((name = args[:in_file]) && (IO.read(name, mode: \"rb\"))) ||\n args[:in_str] ||\n fail(\"An input must be specified.\")\n\n @generator = args[:generator] ||\n ((key = args[:key]) && Generator.new(key)) ||\n fail(\"A key or generator must be specified.\")\n\n @window = args[:window] || 16\n\n #The filler value is for testing purposes only. It should\n #not be specified when secure operation is desired.\n @fill_value = args[:filler]\n end",
"def parse_args\r\n if(cmd.args =~ /\\=/)\r\n self.names = InputFormatter.titlecase_arg(cmd.args.before(\"=\"))\r\n self.action_args = cmd.args.after(\"=\")\r\n elseif (cmd.args && one_word_command)\r\n self.names = InputFormatter.titlecase_arg(cmd.args)\r\n self.action_args = \"\"\r\n else\r\n self.names = enactor.name\r\n self.action_args = cmd.args\r\n end\r\n\r\n self.names = self.names ? self.names.split(/[ ,]/) : nil\r\n\r\n self.combat_command = cmd.switch ? cmd.switch.downcase : nil\r\n end",
"def manage_args(*args)\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n user_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"user_name\",true)\n user_name.setDisplayName(\"What is your name?\")\n args << user_name\n\n #make an argument to add new space true/false\n add_space = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"add_space\",true)\n add_space.setDisplayName(\"Add a space to your model?\")\n add_space.setDefaultValue(true)\n args << add_space\n \n return args\n end",
"def greeting\n puts \"Hello, MTA rider! How can we help?\"\n puts \"please enter one of the following commands:\"\n puts \"lines / stops the_line / calculate Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"\n user_call, *user_args = gets.chomp\n user_args.to_s\n # user_args.split(\" \")\n # puts user_input\n\n if user_call == lines\n show_lines()\n elsif user_call == stops\n show_stops(user_args[0])\n elsif user_call == calculate\n if user_args.length < 4\n puts 'please enter \"Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"'\n puts 'or enter \"exit\" to return to the home screen' \n user_input = gets.chomp\n if user_input == \"exit\"\n greeting()\n end \n user_input = user_input.split(\" \")\n calculate(user_input[0], user_input[1], user_input[2], user_input[3])\n else\n calculate(user_args[0], user_args[1], user_args[2], user_args[3])\n end\n else\n \n end\nend",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n\n\n # Make an argument for evap effectiveness\n input_csv_path = OpenStudio::Measure::OSArgument::makeStringArgument(\"input_csv_folder_path\",true)\n input_csv_path.setDisplayName(\"raw_data_input_folder_path\")\n input_csv_path.setDefaultValue(\"data_file\")\n args << input_csv_path\n\n test_numbers = OpenStudio::StringVector.new\n test_numbers << 'Test_3'\n test_numbers << 'Test_6'\n test_numbers << 'Test_8'\n \n test_names = OpenStudio::StringVector.new\n test_names << 'UA_test'\n test_names << 'Cooling_test'\n test_names << 'Plenum_test'\n\n test_selections = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('test_data',test_numbers,test_names,true)\n\n \n test_selections.setDisplayName(\"Experiment\")\n test_selections.setDefaultValue(\"Test_3\")\n args << test_selections\n\n \n return args\n end",
"def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # URL of the DEnCity server that will be posted to\n hostname = OpenStudio::Ruleset::OSArgument::makeStringArgument('hostname', true)\n hostname.setDisplayName('URL of the DEnCity Server')\n hostname.setDefaultValue('http://www.dencity.org')\n args << hostname\n\n # DEnCity server user id at hostname\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id',true)\n user_id.setDisplayName('User ID for DEnCity Server')\n args << user_id\n\n # DEnCIty server user id's password\n auth_code = OpenStudio::Ruleset::OSArgument::makeStringArgument('auth_code', true)\n auth_code.setDisplayName('Authentication code for User ID on DEnCity server')\n args << auth_code\n\n # Building type for DEnCity's metadata\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDisplayName('Building type')\n args << building_type\n\n # HVAC system for DEnCity's metadata\n primary_hvac = OpenStudio::Ruleset::OSArgument::makeStringArgument('primary_hvac', false)\n primary_hvac.setDisplayName('Primary HVAC system in building')\n args << primary_hvac\n\n args\n\n end",
"def arguments\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n #make choice argument for facade\r\n choices = OpenStudio::StringVector.new\r\n choices << \"MessagePack\"\r\n choices << \"CSV\"\r\n choices << \"Both\"\r\n output_format = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"output_format\", choices)\r\n output_format.setDisplayName(\"Output Format\")\r\n output_format.setDefaultValue(\"Both\")\r\n args << output_format\r\n\r\n args\r\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\t\n #make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"afue\",true)\n afue.setDisplayName(\"Installed AFUE\")\n afue.setUnits(\"Btu/Btu\")\n afue.setDescription(\"The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.\")\n afue.setDefaultValue(1.0)\n args << afue\n\n #make an argument for entering furnace installed supply fan power\n fanpower = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"fan_power_installed\",true)\n fanpower.setDisplayName(\"Installed Supply Fan Power\")\n fanpower.setUnits(\"W/cfm\")\n fanpower.setDescription(\"Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.\")\n fanpower.setDefaultValue(0.5)\n args << fanpower\t\n\t\n #make a string argument for furnace heating output capacity\n furnacecap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n furnacecap.setDisplayName(\"Heating Capacity\")\n furnacecap.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n furnacecap.setUnits(\"kBtu/hr\")\n furnacecap.setDefaultValue(Constants.SizingAuto)\n args << furnacecap\n \n return args\n end",
"def greeting(args)\r\n greet = args[:greet] || \"Hi\"\r\n title = args[:title] || \"Citizen\"\r\n name = args[:name] \r\n puts \"#{greet} #{title} #{name}\"\r\nend",
"def parse_args\n\t\t@args = @args_a.each_slice(2).to_a.inject({}) { |h, k| h[k[0]] = k[1]; h }\n\t\tkeys = @skeys + @lkeys\n\t\t@args.each do |k, v|\n\t\t\tif !keys.include?(k)\n\t\t\t\tputs \"Unknown option `#{k}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif keys.include?(v)\n\t\t\t\tputs \"Missing values for `#{k}' and `#{v}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif v != nil\n\t\t\t\tif v.start_with?('-')\n\t\t\t\t\tputs \"Warning: Value of `#{k}' appears to be a flag\"\n\t\t\t\tend\n\n\t\t\t\tif @static.has_key?(k)\n\t\t\t\t\tif !@static[k].include?(v)\n\t\t\t\t\t\tputs \"Unknown option `#{v}' for `#{k}'\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tif remove_keys(@no_vals).has_blank?\n\t\t\tputs \"Missing argument(s)\"\n\t\t\texit\n\t\tend\t\t\t\n\tend",
"def command_line_arguments(array)\n array.size.times do\n if array.include?('-nc')\n colour_changer(:white)\n array.delete('-nc')\n elsif array.any? { |x| ['-d1', '-d2', '-d3', '-d4'].include? x }\n key = (array[0])[1, 2].to_sym\n @difficulty = DIFFICULTY[key]\n @promptarr = prompt_select(key)\n @intro = false\n end\n end\n end",
"def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n \n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n \n # TODO: argument for subset of output meters\n \n return args\n end",
"def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"RunPeriod\"\n arg = OpenStudio::Measure::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n arg.setDisplayName(\"Reporting Frequency\")\n arg.setDefaultValue(\"Hourly\")\n args << arg\n\n #make an argument for including optional output variables\n arg = OpenStudio::Measure::OSArgument::makeBoolArgument(\"inc_output_variables\", true)\n arg.setDisplayName(\"Include Output Variables\")\n arg.setDefaultValue(false)\n args << arg\n\n return args\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for entering furnace installed afue\n userdefined_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"userdefinedeff\",true)\n userdefined_eff.setDisplayName(\"Efficiency\")\n\tuserdefined_eff.setUnits(\"Btu/Btu\")\n\tuserdefined_eff.setDescription(\"The efficiency of the electric baseboard.\")\n userdefined_eff.setDefaultValue(1.0)\n args << userdefined_eff\n\n #make a choice argument for furnace heating output capacity\n cap_display_names = OpenStudio::StringVector.new\n cap_display_names << Constants.SizingAuto\n (5..150).step(5) do |kbtu|\n cap_display_names << \"#{kbtu} kBtu/hr\"\n end\n\n #make a string argument for furnace heating output capacity\n selected_baseboardcap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"selectedbaseboardcap\", cap_display_names, true)\n selected_baseboardcap.setDisplayName(\"Heating Output Capacity\")\n selected_baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << selected_baseboardcap\n\t\n return args\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for entering baseboard efficiency\n baseboardeff = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"efficiency\",true)\n baseboardeff.setDisplayName(\"Efficiency\")\n baseboardeff.setUnits(\"Btu/Btu\")\n baseboardeff.setDescription(\"The efficiency of the electric baseboard.\")\n baseboardeff.setDefaultValue(1.0)\n args << baseboardeff\n\n #make a string argument for baseboard heating output capacity\n baseboardcap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n baseboardcap.setDisplayName(\"Heating Capacity\")\n baseboardcap.setDescription(\"The output heating capacity of the electric baseboard. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n baseboardcap.setUnits(\"kBtu/hr\")\n baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << baseboardcap\n\t\n return args\n end",
"def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend",
"def cmdarg; end",
"def cmdarg; end",
"def cmdarg; end",
"def check_inputs_g(args)\n raise TypeError, Ajaila::Messager.warning(\"Nothing to generate...\") if args == []\n raise TypeError, Ajaila::Messager.warning(\"Only miners, selectors, presenters supported\\n(ex. miner SomeMiner, selector SomeSelector,\\n presenter SomePresenter, table SomeTable)\") if KNOWN_INSTANCES.include?(args[0]) == false\n raise TypeError, Ajaila::Messager.warning(\"Your #{args[0]} needs a name!\") if args[1] == nil\n raise TypeError, Ajaila::Messager.warning(\"Wrong format of the #{args[0]} name (use only A-Z and a-z symbols)\") if args[1][/^[A-Z]+$/i] == nil\n return 0\n end",
"def arguments\n parser.arguments\n end",
"def valid_args(type)\n case type\n when 'search' then %i[q format addressdetails extratags namedetails viewbox bounded exclude_place_ids limit accept-language email]\n when 'reverse' then %i[format lat lon zoom addressdetails extratags namedetails accept-language email]\n else []\n end\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n id = OpenStudio::Measure::OSArgument.makeStringArgument('feature_id', false)\n id.setDisplayName('Feature unique identifier')\n id.setDefaultValue('1')\n args << id\n\n name = OpenStudio::Measure::OSArgument.makeStringArgument('feature_name', false)\n name.setDisplayName('Feature scenario specific name')\n name.setDefaultValue('name')\n args << name\n\n feature_type = OpenStudio::Measure::OSArgument.makeStringArgument('feature_type', false)\n feature_type.setDisplayName('URBANopt Feature Type')\n feature_type.setDefaultValue('Building')\n args << feature_type\n\n feature_location = OpenStudio::Measure::OSArgument.makeStringArgument('feature_location', false)\n feature_location.setDisplayName('URBANopt Feature Location')\n feature_location.setDefaultValue('0')\n args << feature_location\n\n # make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n # reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'BillingPeriod' # match it to utility bill object\n ## Utility report here to report the start and end for each fueltype\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDescription('The frequency at which to report timeseries output data.')\n reporting_frequency.setDefaultValue('Timestep')\n args << reporting_frequency\n\n return args\n end",
"def madlib_inputs\n print \"Enter a noun: \" \n noun = gets.chomp\n print \"Enter a verb: \" \n verb = gets.chomp\n print \"Enter an adjective: \" \n adjective = gets.chomp\n print \"Enter an adverb: \" \n adverb = gets.chomp\n madlib_line(noun, verb, adjective, adverb)\nend",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make a start date argument\n start_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"start_date\",true)\n start_date.setDisplayName(\"Start date\")\n args << start_date\n \n #make an end date argument\n end_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"end_date\",true)\n end_date.setDisplayName(\"End date\")\n args << end_date\n \n return args\n end",
"def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end",
"def process_arguments\n # clean unsupport symbols, e.g. JieFang;\n # or error argument due to option typo, e.g. '-list' will put 'ist' into the array in this src.\n @support_newspapers = Array.new #TODO: move to elsewhere\n @support_newspapers << :XM\n @support_newspapers << :WHB\n @support_newspapers << :YZ\n # ATTENTION: command line input is an array of string, to be consistent, internally I use only symbol when using this symbol\n @options.newspapers = @options.newspapers.collect { | item | item.to_sym } & @support_newspapers\n \n if @options.newspapers.size == 0\n @support_newspapers.each do | sym |\n @options.newspapers << sym\n end\n end\n end",
"def args\n raw_args\n end",
"def argv; end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n code_choices = OpenStudio::StringVector.new \n code_choices << \"ASHRAE 90.1-2007\" \n code_choices << \"ASHRAE 90.1-2010\" \n energy_code = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('energy_code', code_choices, true)\n energy_code.setDisplayName(\"Code baseline\")\n energy_code.setDefaultValue(\"ASHRAE 90.1-2010\")\n args << energy_code\n \n #make an argument to add new space true/false\n leed_check = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"leed_check\",true)\n leed_check.setDisplayName(\"Perform typical LEED checks?\")\n leed_check.setDefaultValue(true)\n args << leed_check\n \n return args\n end",
"def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \t\"os_object_type\"\t],\n [ \"weather_file_name\", \"STRING\", true, false, \"Weather File Name\", nil, nil, nil, nil, \t nil\t\t\t\t\t],\n #Default set for server weather folder.\n [ \"weather_directory\", \"STRING\", true, false, \"Weather Directory\", \"../../weather\", nil, nil, nil,\t nil\t\t\t\t\t]\n \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end",
"def inflamed _args\n \"inflamed _args;\" \n end",
"def more_options\n puts Rainbow(\"Specify your additional options for your search: 'release date', 'search history', or go back\").yellow.underline\n input = gets.chomp.downcase\n \n if input == \"release date\"\n option_release_date\n \n elsif input == \"search history\"\n game_history\n\n elsif input == \"go back\"\n continue_or_exit\n \n else \n puts \"Input not recognized please try again\"\n more_options\n end\n end",
"def cmd(options={})\n arguments\n end",
"def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # this measure will require arguments, but at this time, they are not known\n geometry_profile = OpenStudio::Ruleset::OSArgument::makeStringArgument('geometry_profile', true)\n geometry_profile.setDefaultValue(\"{}\")\n os_model = OpenStudio::Ruleset::OSArgument::makeStringArgument('os_model', true)\n os_model.setDefaultValue('multi-model mode')\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id', true)\n user_id.setDefaultValue(\"00000000-0000-0000-0000-000000000000\")\n job_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('job_id', true)\n #job_id.setDefaultValue(SecureRandom.uuid.to_s)\n ashrae_climate_zone = OpenStudio::Ruleset::OSArgument::makeStringArgument('ashrae_climate_zone', false)\n ashrae_climate_zone.setDefaultValue(\"-1\")\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDefaultValue(\"BadDefaultType\")\n\n args << geometry_profile\n args << os_model\n args << user_id\n args << job_id\n args << ashrae_climate_zone\n args << building_type\n\n return args\n end",
"def user_input\n\tgets\nend",
"def input\n @input ||= args.dig(:input)\n end",
"def parse_args\n require 'optimist'\n opts = Optimist.options do\n opt :source, \"Inventory Source UID\", :type => :string, :required => ENV[\"SOURCE_UID\"].nil?, :default => ENV[\"SOURCE_UID\"]\n opt :ingress_api, \"Hostname of the ingress-api route\", :type => :string, :default => ENV[\"INGRESS_API\"] || \"http://localhost:9292\"\n opt :config, \"Configuration file name\", :type => :string, :default => ENV[\"CONFIG\"] || \"default\"\n opt :data, \"Amount & custom values of generated items\", :type => :string, :default => ENV[\"DATA\"] || \"default\"\n end\n\n opts\nend",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # lat arg\n lat = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lat\", true)\n lat.setDisplayName(\"Latitude\")\n lat.setDefaultValue(39.7392000000)\n args << lat\n\n # long arg\n lon = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lon\", true)\n lon.setDisplayName(\"Longitude\")\n lon.setDefaultValue(-104.9903000000)\n args << lon\n\n return args\n end",
"def add args\n db = get_db\n if args.empty?\n print \"Enter a short summary: \"\n STDOUT.flush\n text = gets.chomp\n if text.empty?\n exit ERRCODE\n end\n else\n # if you add last arg as P1..P5, I'll update priority automatically\n if args.last =~ /P[1-5]/\n $default_priority = args.pop\n end\n text = args.join \" \"\n end\n # convert actual newline to C-a. slash n's are escapes so echo -e does not muck up.\n #atitle=$( echo \"$atitle\" | tr -cd '\\40-\\176' )\n text.tr! \"\\n\", '\u0001'\n title = text\n desc = nil\n if $prompt_desc\n # choice of vim or this XXX also how to store in case of error or abandon\n # and allow user to edit, so no retyping. This could be for mult fields\n message \"Enter a detailed description (. to exit): \"\n desc = Cmdapp.get_lines\n #message \"You entered #{desc}\"\n end\n type = $default_type || \"bug\"\n severity = $default_severity || \"normal\"\n status = $default_status || \"open\"\n priority = $default_priority || \"P3\"\n if $prompt_type\n type = Cmdapp._choice(\"Select type:\", %w[bug enhancement feature task] )\n #message \"You selected #{type}\"\n end\n if $prompt_priority\n #priority = Cmdapp._choice(\"Select priority:\", %w[normal critical moderate] )\n priority = ask_priority\n #message \"You selected #{severity}\"\n end\n if $prompt_severity\n severity = Cmdapp._choice(\"Select severity:\", %w[normal critical moderate] )\n #message \"You selected #{severity}\"\n end\n if $prompt_status\n status = Cmdapp._choice(\"Select status:\", %w[open started closed stopped canceled] )\n #message \"You selected #{status}\"\n end\n assigned_to = $default_assigned_to\n if $prompt_assigned_to\n message \"Assign to:\"\n #assigned_to = $stdin.gets.chomp\n assigned_to = Cmdapp._gets \"assigned_to\", \"assigned_to\", $default_assigned_to\n #message \"You selected #{assigned_to}\"\n end\n project = component = version = nil\n # project\n if $use_project\n project = Cmdapp.user_input('project', $prompt_project, nil, $valid_project, $default_project)\n end\n if $use_component\n component = Cmdapp.user_input('component', $prompt_component, nil, $valid_component, $default_component)\n end\n if $use_version\n version = Cmdapp.user_input('version', $prompt_version, nil, $valid_version, $default_version)\n end\n\n start_date = @now\n due_date = default_due_date\n comment_count = 0\n priority ||= \"P3\" \n description = desc\n fix = nil #\"Some long text\" \n #date_created = @now\n #date_modified = @now\n body = {}\n body[\"title\"]=title\n body[\"description\"]=description\n body[\"type\"]=type\n body[\"status\"]=status\n body[\"start_date\"]=start_date.to_s\n body[\"due_date\"]=due_date.to_s\n body[\"priority\"]=priority\n body[\"severity\"]=severity\n body[\"assigned_to\"]=assigned_to\n body[\"created_by\"] = $default_user\n # only insert if its wanted by user\n body[\"project\"]=project if $use_project\n body[\"component\"]=component if $use_component\n body[\"version\"]=version if $use_version\n\n rowid = db.table_insert_hash(\"bugs\", body)\n puts \"Issue #{rowid} created\"\n logid = db.sql_logs_insert rowid, \"create\", \"#{rowid} #{type}: #{title}\"\n body[\"id\"] = rowid\n mail_issue nil, body\n \n 0\n end",
"def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end",
"def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end",
"def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"Whole Building\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n\r\n return args\r\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\t\t\n\n #Make a string argument for occupants (auto or number)\n num_occ = OpenStudio::Measure::OSArgument::makeStringArgument(\"num_occ\", false)\n num_occ.setDisplayName(\"Number of Occupants\")\n num_occ.setDescription(\"Specify the number of occupants. For a multifamily building, specify one value for all units or a comma-separated set of values (in the correct order) for each unit. A value of '#{Constants.Auto}' will calculate the average number of occupants from the number of bedrooms. Used to specify the internal gains from people only.\")\n num_occ.setDefaultValue(Constants.Auto)\n args << num_occ\n\n #Make a string argument for 24 weekday schedule values\n weekday_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekday_sch\", true)\n weekday_sch.setDisplayName(\"Weekday schedule\")\n weekday_sch.setDescription(\"Specify the 24-hour weekday schedule.\")\n weekday_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekday_sch\n \n #Make a string argument for 24 weekend schedule values\n weekend_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekend_sch\", true)\n weekend_sch.setDisplayName(\"Weekend schedule\")\n weekend_sch.setDescription(\"Specify the 24-hour weekend schedule.\")\n weekend_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekend_sch\n\n #Make a string argument for 12 monthly schedule values\n monthly_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"monthly_sch\", true)\n monthly_sch.setDisplayName(\"Month schedule\")\n monthly_sch.setDescription(\"Specify the 12-month schedule.\")\n monthly_sch.setDefaultValue(\"1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0\")\n args << monthly_sch\n\n return args\n end",
"def validate_arguments()\n usage unless ARGV.count > 0\nend",
"def input args\n if args.state.inputlist.length > 5\n args.state.inputlist.pop\n end\n\n should_process_special_move = (args.inputs.keyboard.key_down.j) ||\n (args.inputs.keyboard.key_down.k) ||\n (args.inputs.keyboard.key_down.a) ||\n (args.inputs.keyboard.key_down.d) ||\n (args.inputs.controller_one.key_down.y) ||\n (args.inputs.controller_one.key_down.x) ||\n (args.inputs.controller_one.key_down.left) ||\n (args.inputs.controller_one.key_down.right)\n\n if (should_process_special_move)\n if (args.inputs.keyboard.key_down.j && args.inputs.keyboard.key_down.k) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"shield\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.inputlist[0] == \"forward-attack\") && ((args.state.tick_count - args.state.lastpush) <= 15)\n args.state.inputlist.unshift(\"dash-attack\")\n args.state.player.dx = 20\n elsif (args.inputs.keyboard.key_down.j && args.inputs.keyboard.a) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.left)\n args.state.inputlist.unshift(\"back-attack\")\n elsif ( args.inputs.controller_one.key_down.x || args.inputs.keyboard.key_down.j)\n args.state.inputlist.unshift(\"forward-attack\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.player.y > 128)\n args.state.inputlist.unshift(\"dair\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"up-attack\")\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) &&\n (args.state.inputlist[0] == \"<\") &&\n ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.inputlist.unshift(\"<<\")\n args.state.player.dx = -15\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a)\n args.state.inputlist.unshift(\"<\")\n args.state.timeleft = args.state.tick_count\n elsif (args.inputs.controller_one.key_down.right || args.inputs.keyboard.key_down.d)\n args.state.inputlist.unshift(\">\")\n end\n\n args.state.lastpush = args.state.tick_count\n end\n\n if args.inputs.keyboard.space || args.inputs.controller_one.r2 # if the user presses the space bar\n args.state.player.jumped_at ||= args.state.tick_count # jumped_at is set to current frame\n\n # if the time that has passed since the jump is less than the player's jump duration and\n # the player is not falling\n if args.state.player.jumped_at.elapsed_time < args.state.player_jump_power_duration && !args.state.player.falling\n args.state.player.dy = args.state.player_jump_power # change in y is set to power of player's jump\n end\n end\n\n # if the space bar is in the \"up\" state (or not being pressed down)\n if args.inputs.keyboard.key_up.space || args.inputs.controller_one.key_up.r2\n args.state.player.jumped_at = nil # jumped_at is empty\n args.state.player.falling = true # the player is falling\n end\n\n if args.inputs.left # if left key is pressed\n if args.state.player.dx < -5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = -5\n end\n\n elsif args.inputs.right # if right key is pressed\n if args.state.player.dx > 5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = 5\n end\n else\n args.state.player.dx *= args.state.player_speed_slowdown_rate # dx is scaled down\n end\n\n if ((args.state.player.dx).abs > 5) #&& ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.player.dx *= 0.95\n end\nend",
"def arguments(model = nil)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n chs = OpenStudio::StringVector.new\n chs << 'Last OSM'\n chs << 'Last IDF'\n file_source = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('file_source', chs, true)\n file_source.setDisplayName('Model Source')\n file_source.setDefaultValue('Last OSM')\n args << file_source\n\n chs = OpenStudio::StringVector.new\n chs << 'Timestep'\n chs << 'Hourly'\n reporting_frequency = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('reporting_frequency', chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n variable1_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable1_name', true)\n variable1_name.setDisplayName('Variable 1 Name')\n variable1_name.setDefaultValue('Surface Outside Face Temperature')\n args << variable1_name\n\n variable2_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable2_name', true)\n variable2_name.setDisplayName('Variable 2 Name')\n variable2_name.setDefaultValue('Surface Inside Face Temperature')\n args << variable2_name\n\n variable3_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable3_name', true)\n variable3_name.setDisplayName('Variable 3 Name')\n variable3_name.setDefaultValue('Zone Mean Radiant Temperature')\n args << variable3_name\n\n return args\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Create a list of the names and handles of space types\n # used in the building.\n used_space_type_handles = OpenStudio::StringVector.new\n used_space_type_names = OpenStudio::StringVector.new\n model.getSpaceTypes.sort.each do |space_type|\n if space_type.spaces.size > 0 # only show space types used in the building\n used_space_type_handles << space_type.handle.to_s\n used_space_type_names << space_type.name.to_s\n end\n end\n\t\n # Make an argument for plenum space type\n ceiling_return_plenum_space_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"ceiling_return_plenum_space_type\", used_space_type_handles, used_space_type_names,false)\n ceiling_return_plenum_space_type.setDisplayName(\"This space type should be part of a ceiling return air plenum.\")\n args << ceiling_return_plenum_space_type\n\t\n # Make a bool argument to edit/not edit each space type\n\t\tmodel.getSpaceTypes.sort.each do |space_type|\n\t\t\tif space_type.spaces.size > 0 # only show space types used in the building\n\t\t\t\tspace_type_to_edit = OpenStudio::Ruleset::OSArgument::makeBoolArgument(space_type.name.get.to_s,false)\n\t\t\t\t# Make a bool argument for this space type\n\t\t\t\tspace_type_to_edit.setDisplayName(\"Add #{space_type.name.get} space type to GSHP system?\")\n\t\t\t\tspace_type_to_edit.setDefaultValue(false)\t\t\n\t\t\t\targs << space_type_to_edit\n\t\t\tend\n\t\tend\n\t \n\t\t# Heating COP of GSHP\n\t\tgshp_htg_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_htg_cop\",false)\n\t\tgshp_htg_cop.setDisplayName(\"GSHP DX Heating Coil Heating COP\")\n\t\tgshp_htg_cop.setDefaultValue(4.0)\n\t\targs << gshp_htg_cop\n\t\t\n\t\t# Cooling EER of GSHP\n\t\tgshp_clg_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_clg_eer\",false)\n\t\tgshp_clg_eer.setDisplayName(\"GSHP DX Cooling Coil Cooling EER\")\n\t\tgshp_clg_eer.setDefaultValue(14)\n\t\targs << gshp_clg_eer\n\t\t\n\t\t# GSHP Fan Type PSC or ECM\n\t\tfan_choices = OpenStudio::StringVector.new\n\t\tfan_choices << \"PSC\"\n\t\tfan_choices << \"ECM\"\n\t\tgshp_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"gshp_fan_type\",fan_choices,true) # note ECM fan type may correspond to different set of heat pump performance curves\n\t\tgshp_fan_type.setDisplayName(\"GSHP Fan Type: PSC or ECM?\")\n\t\tgshp_fan_type.setDefaultValue(\"PSC\")\n args << gshp_fan_type\n\t\t\n\t\t# Condenser Loop Cooling Temperature\n\t\t# condLoopCoolingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopCoolingTemp\",false)\n\t\t# condLoopCoolingTemp.setDisplayName(\"Condenser Loop Cooling Temperature (F)\")\n\t\t# condLoopCoolingTemp.setDefaultValue(90)\n\t\t# args << condLoopCoolingTemp\n\t\t\n\t\t# Condenser Loop Heating Temperature\n\t\t# condLoopHeatingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopHeatingTemp\",false)\n\t\t# condLoopHeatingTemp.setDisplayName(\"Condenser Loop Heating Temperature (F)\")\n\t\t# condLoopHeatingTemp.setDefaultValue(60)\t\n\t\t# args << condLoopHeatingTemp\n\t\t\n\t\t# Vertical Bore HX\n\t\tbuilding_area = model.getBuilding.floorArea \n\t\tbuilding_cool_ton = building_area*10.7639/500\t\t# 500sf/ton estimated\n\t\tbore_hole_no = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"bore_hole_no\",false)\n\t\tbore_hole_no.setDisplayName(\"Number of Bore Holes\")\n\t\tbore_hole_no.setDefaultValue(building_cool_ton.to_i) \n\t\targs << bore_hole_no\n\n\t\t\n\t\tbore_hole_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_length\",false)\n\t\tbore_hole_length.setDisplayName(\"Bore Hole Length (ft)\")\n\t\tbore_hole_length.setDefaultValue(200)\n\t\targs << bore_hole_length\n\n\t\tbore_hole_radius = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_radius\",false)\n\t\tbore_hole_radius.setDisplayName(\"Bore Hole Radius (inch)\")\n\t\tbore_hole_radius.setDefaultValue(6.0)\n\t\targs << bore_hole_radius\n\t\t\n\t\tground_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ground_k_value\",false)\n\t\tground_k_value.setDisplayName(\"Ground Conductivity (Btu/hr.F.R\")\n\t\tground_k_value.setDefaultValue(0.75)\n\t\targs << ground_k_value\n\t\t\n\t\tgrout_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"grout_k_value\",false)\n\t\tgrout_k_value.setDisplayName(\"Grout Conductivity (Btu/hr.F.R\")\n\t\tgrout_k_value.setDefaultValue(0.75)\n\t\targs << grout_k_value\n\t\t\n\t\tchs = OpenStudio::StringVector.new\n\t\tchs << \"Yes\"\n\t\tchs << \"No\"\n\t\tsupplemental_boiler = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"supplemental_boiler\",chs, true)\n\t\tsupplemental_boiler.setDisplayName(\"Supplemental Heating Boiler?\")\n\t\tsupplemental_boiler.setDefaultValue(\"No\")\n\t\targs << supplemental_boiler\n\t\t\n\t\t# Boiler Capacity\n\t\tboiler_cap = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_cap\",false)\n\t\tboiler_cap.setDisplayName(\"boiler normal capacity (MBtuh)\")\n\t\tboiler_cap.setDefaultValue(500.0)\n\t\targs << boiler_cap\n\t\t\t\t\n\t\t# Boiler Efficiency\n\t\tboiler_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_eff\",false)\n\t\tboiler_eff.setDisplayName(\"Boiler Thermal Efficiency\")\n\t\tboiler_eff.setDefaultValue(0.9)\n\t\targs << boiler_eff\n\t\t\n\t\t# Boiler fuel Type\n\t\tfuel_choices = OpenStudio::StringVector.new\n\t\tfuel_choices << \"NaturalGas\"\n\t\tfuel_choices << \"PropaneGas\"\n\t\tfuel_choices << \"FuelOil#1\"\n\t\tfuel_choices << \"FuelOil#2\"\n\t\tfuel_choices << \"Electricity\"\n\t\tboiler_fuel_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"boiler_fuel_type\",fuel_choices,false) \n\t\tboiler_fuel_type.setDisplayName(\"Boiler Fuel Type\")\n\t\tboiler_fuel_type.setDefaultValue(\"NaturalGas\")\n\t\targs << boiler_fuel_type\n\t\t\n\t\t# boiler Hot water supply temperature\n\t\tboiler_hw_st = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_hw_st\",false)\n\t\tboiler_hw_st.setDisplayName(\"Boiler Design Heating Water Outlet Temperature (F)\")\n\t\tboiler_hw_st.setDefaultValue(120)\t\n\t\targs << boiler_hw_st\n\t\t\n\t\t# DOAS Fan Type\n\t\tdoas_fan_choices = OpenStudio::StringVector.new\n\t\tdoas_fan_choices << \"Constant\"\n\t\tdoas_fan_choices << \"Variable\"\n\t\tdoas_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_fan_type\",doas_fan_choices,true)\n\t\tdoas_fan_type.setDisplayName(\"DOAS Fan Flow Control - Variable means DCV controls\")\n\t\tdoas_fan_type.setDefaultValue(\"Variable\")\n\t\targs << doas_fan_type\n\t\t\n\t\t# DOAS Energy Recovery\n\t\terv_choices = OpenStudio::StringVector.new\n\t\terv_choices << \"plate w/o economizer lockout\"\n\t\terv_choices << \"plate w/ economizer lockout\"\n\t\terv_choices << \"rotary wheel w/o economizer lockout\"\n\t\terv_choices << \"rotary wheel w/ economizer lockout\"\n\t\terv_choices << \"none\"\n\t\tdoas_erv = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_erv\",erv_choices,true)\n\t\tdoas_erv.setDisplayName(\"DOAS Energy Recovery?\")\n\t\tdoas_erv.setDefaultValue(\"none\")\n\t\targs << doas_erv\n\t\t\n\t\t# DOAS Evaporative Cooling\n\t\tevap_choices = OpenStudio::StringVector.new\n\t\tevap_choices << \"Direct Evaporative Cooler\"\n\t\tevap_choices << \"none\"\n\t\tdoas_evap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_evap\",evap_choices,true)\n\t\tdoas_evap.setDisplayName(\"DOAS Direct Evaporative Cooling?\")\n\t\tdoas_evap.setDefaultValue(\"none\")\n\t\targs << doas_evap\n\t\t\n\t\t# DOAS DX Cooling\n\t\tdoas_dx_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"doas_dx_eer\",false)\n\t\tdoas_dx_eer.setDisplayName(\"DOAS DX Cooling EER\")\n\t\tdoas_dx_eer.setDefaultValue(10.0)\n\t\targs << doas_dx_eer\n\t\n # make an argument for material and installation cost\n # todo - I would like to split the costing out to the air loops weighted by area of building served vs. just sticking it on the building\n cost_total_hvac_system = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cost_total_hvac_system\",true)\n cost_total_hvac_system.setDisplayName(\"Total Cost for HVAC System ($).\")\n cost_total_hvac_system.setDefaultValue(0.0)\n args << cost_total_hvac_system\n \n #make an argument to remove existing costs\n remake_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"remake_schedules\",true)\n remake_schedules.setDisplayName(\"Apply recommended availability and ventilation schedules for air handlers?\")\n remake_schedules.setDefaultValue(true)\n args << remake_schedules\n\n return args\n end",
"def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n stp = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"stp\", true)\r\n stp.setDisplayName(\"Timeseries Timestep\")\r\n stp.setDescription(\"Timeseries Timestep\")\r\n stp.setDefaultValue(\"Zone Timestep\")\r\n args << stp\r\n \r\n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\r\n env.setDisplayName(\"availableEnvPeriods\")\r\n env.setDescription(\"availableEnvPeriods\")\r\n env.setDefaultValue(\"RUN PERIOD 1\")\r\n args << env\r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n scale = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"scale\", true)\r\n scale.setDisplayName(\"scale factor to apply to the difference\")\r\n scale.setDescription(\"scale factor to apply to the difference\")\r\n scale.setDefaultValue(1)\r\n args << scale \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n \r\n algorithm_download = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"algorithm_download\", true)\r\n algorithm_download.setDisplayName(\"algorithm_download\")\r\n algorithm_download.setDescription(\"algorithm_download\")\r\n algorithm_download.setDefaultValue(false)\r\n args << algorithm_download \r\n \r\n plot_flag = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"plot_flag\", true)\r\n plot_flag.setDisplayName(\"plot_flag timeseries data\")\r\n plot_flag.setDescription(\"plot_flag timeseries data\")\r\n plot_flag.setDefaultValue(true)\r\n args << plot_flag\r\n \r\n plot_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"plot_name\", true)\r\n plot_name.setDisplayName(\"Plot name\")\r\n plot_name.setDescription(\"Plot name\")\r\n plot_name.setDefaultValue(\"\")\r\n args << plot_name\r\n \r\n warning_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"warning_messages\", true)\r\n warning_messages.setDisplayName(\"warning_messages\")\r\n warning_messages.setDescription(\"warning_messages\")\r\n warning_messages.setDefaultValue(false)\r\n args << warning_messages\r\n\r\n return args\r\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # the name of the space to add to the model\n setpoint = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"setpoint_temperature\", true)\n setpoint.setUnits(\"Degrees Celsius\")\n setpoint.setDisplayName(\"Ambient Loop Temperature\")\n setpoint.setDefaultValue(20)\n setpoint.setDescription(\"Temperature setpoint for the ambient loop\")\n args << setpoint\n\n delta = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"design_delta\", true)\n delta.setUnits(\"Delta Temperature\")\n delta.setDefaultValue(5.55) # 10 Deg F default delta\n delta.setDisplayName(\"Delta Design Loop Temperature\")\n delta.setDescription(\"Delta design temperature for the ambient loop\")\n args << delta\n\n return args\n end",
"def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n return args\n end",
"def print_two_again(arg1, arg2) # Non-variable list of inputs it will accept\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def commander _args\n \"commander _args;\" \n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make a string argument for furnace fuel type\n fuel_display_names = OpenStudio::StringVector.new\n fuel_display_names << Constants.FuelTypeGas\n fuel_display_names << Constants.FuelTypeOil\n fuel_display_names << Constants.FuelTypePropane\n fuel_display_names << Constants.FuelTypeElectric\n fuel_type = OpenStudio::Measure::OSArgument::makeChoiceArgument('fuel_type', fuel_display_names, true)\n fuel_type.setDisplayName('Fuel Type')\n fuel_type.setDescription('Type of fuel used for heating.')\n fuel_type.setDefaultValue(Constants.FuelTypeGas)\n args << fuel_type\n\n # make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument('afue', true)\n afue.setDisplayName('Installed AFUE')\n afue.setUnits('Btu/Btu')\n afue.setDescription('The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.')\n afue.setDefaultValue(0.78)\n args << afue\n\n # make an argument for entering furnace installed supply fan power\n fan_power_installed = OpenStudio::Measure::OSArgument::makeDoubleArgument('fan_power_installed', true)\n fan_power_installed.setDisplayName('Installed Supply Fan Power')\n fan_power_installed.setUnits('W/cfm')\n fan_power_installed.setDescription('Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.')\n fan_power_installed.setDefaultValue(0.5)\n args << fan_power_installed\n\n # make a string argument for furnace heating output capacity\n capacity = OpenStudio::Measure::OSArgument::makeStringArgument('capacity', true)\n capacity.setDisplayName('Heating Capacity')\n capacity.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n capacity.setUnits('kBtu/hr')\n capacity.setDefaultValue(Constants.SizingAuto)\n args << capacity\n\n # make a string argument for distribution system efficiency\n dse = OpenStudio::Measure::OSArgument::makeStringArgument('dse', true)\n dse.setDisplayName('Distribution System Efficiency')\n dse.setDescription('Defines the energy losses associated with the delivery of energy from the equipment to the source of the load.')\n dse.setDefaultValue('NA')\n args << dse\n\n # make a bool argument for open hvac flue\n has_hvac_flue = OpenStudio::Measure::OSArgument::makeBoolArgument('has_hvac_flue', true)\n has_hvac_flue.setDisplayName('Air Leakage: Has Open HVAC Flue')\n has_hvac_flue.setDescription('Specifies whether the building has an open flue associated with the HVAC system.')\n has_hvac_flue.setDefaultValue(true)\n args << has_hvac_flue\n\n return args\n end",
"def args\n @args\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n return args\n end",
"def default_args(a,b,c=1)\n puts \"\\nValues of variables: \",a,b,c\nend",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n \t#Make a string argument for 24 weekday cooling set point values\n clg_wkdy = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wkdy\", false)\n clg_wkdy.setDisplayName(\"Weekday Setpoint\")\n clg_wkdy.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekdays.\")\n clg_wkdy.setUnits(\"degrees F\")\n clg_wkdy.setDefaultValue(\"76\")\n args << clg_wkdy \n \n \t#Make a string argument for 24 weekend cooling set point values\n clg_wked = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wked\", false)\n clg_wked.setDisplayName(\"Weekend Setpoint\")\n clg_wked.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekend.\")\n clg_wked.setUnits(\"degrees F\")\n clg_wked.setDefaultValue(\"76\")\n args << clg_wked\t\n\t\n return args\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n # this measure does not require any user arguments, return an empty list\n return args\n end"
] |
[
"0.73753476",
"0.73753476",
"0.73753476",
"0.70890766",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.68296087",
"0.6826596",
"0.67602986",
"0.67480284",
"0.6589929",
"0.6581451",
"0.6579882",
"0.65468127",
"0.6503042",
"0.647451",
"0.64706385",
"0.64699155",
"0.6469245",
"0.64641875",
"0.64103556",
"0.6389132",
"0.637863",
"0.6374086",
"0.6373223",
"0.63639134",
"0.6358853",
"0.6347805",
"0.63475585",
"0.63470906",
"0.6329135",
"0.63280094",
"0.62932867",
"0.6289945",
"0.6271416",
"0.6257277",
"0.6257238",
"0.6239814",
"0.6235555",
"0.62354916",
"0.6221531",
"0.6221531",
"0.6221531",
"0.62026656",
"0.61958784",
"0.61795026",
"0.61696565",
"0.6168981",
"0.6167551",
"0.6165484",
"0.6161183",
"0.6146112",
"0.6128867",
"0.611614",
"0.6099537",
"0.609091",
"0.608763",
"0.6082464",
"0.60754794",
"0.6075173",
"0.60703015",
"0.6069249",
"0.6053929",
"0.60461015",
"0.6037139",
"0.6037139",
"0.603555",
"0.6028014",
"0.60276234",
"0.6026254",
"0.6021278",
"0.6006005",
"0.60050625",
"0.60002536",
"0.5998068",
"0.5990844",
"0.5986098",
"0.59826887",
"0.59739846",
"0.59692407",
"0.59684443",
"0.5966365",
"0.59595567"
] |
0.0
|
-1
|
define what happens when the measure is run
|
def run(model, runner, user_arguments)
super(model, runner, user_arguments)
# use the built-in error checking
if !runner.validateUserArguments(arguments(model), user_arguments)
return false
end
# assign the user inputs to variables
remove_unused_space_types = runner.getBoolArgumentValue("remove_unused_space_types",user_arguments)
remove_unused_load_defs = runner.getBoolArgumentValue("remove_unused_load_defs",user_arguments)
remove_unused_schedules = runner.getBoolArgumentValue("remove_unused_schedules",user_arguments)
remove_unused_constructions = runner.getBoolArgumentValue("remove_unused_constructions",user_arguments)
# report initial condition of model
runner.registerInitialCondition("The model started with #{model.numObjects.to_s} objects.")
# remove orphan space infiltration objects
orphan_flag = false
model.getSpaceInfiltrationDesignFlowRates.sort.each do |instance|
if instance.spaceType.is_initialized == false and instance.space.is_initialized == false
runner.registerInfo("Removing orphan space infiltration object named #{instance.name}")
instance.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan space infiltration objects were found")
end
# todo - add section to remove orphan effective leakage
# remove orphan design spec oa objects
orphan_flag = false
model.getDesignSpecificationOutdoorAirs.sort.each do |instance|
if instance.directUseCount == 0
runner.registerInfo("Removing orphan design specification outdoor air object named #{instance.name}")
instance.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan design specification outdoor air objects were found")
end
# remove orphan load instances
orphan_flag = false
model.getSpaceLoadInstances.sort.each do |instance|
if instance.spaceType.is_initialized == false and instance.space.is_initialized == false
# extra check for water use equipment. They may or may not have space. But they should have a water use connection
if instance.to_WaterUseEquipment.is_initialized and instance.to_WaterUseEquipment.get.waterUseConnections.is_initialized
next
end
runner.registerInfo("Removing orphan load instance object named #{instance.name}")
instance.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan load instance objects were found")
end
# remove orphan surfaces
orphan_flag = false
model.getSurfaces.sort.each do |surface|
if not surface.space.is_initialized
runner.registerInfo("Removing orphan base surface named #{surface.name}")
surface.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan base surfaces were found")
end
# remove orphan subsurfaces
orphan_flag = false
model.getSubSurfaces.sort.each do |subsurface|
if not subsurface.surface.is_initialized
runner.registerInfo("Removing orphan sub surface named #{subsurface.name}")
subsurface.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan sub surfaces were found")
end
# remove orphan shading surfaces
orphan_flag = false
model.getShadingSurfaces.sort.each do |surface|
if not surface.shadingSurfaceGroup.is_initialized
runner.registerInfo("Removing orphan shading surface named #{surface.name}")
surface.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan shading surfaces were found")
end
# remove orphan interior partition surfaces
orphan_flag = false
model.getInteriorPartitionSurfaces.sort.each do |surface|
if not surface.interiorPartitionSurfaceGroup.is_initialized
runner.registerInfo("Removing orphan interior partition surface named #{surface.name}")
surface.remove
orphan_flag = true
end
end
if not orphan_flag
runner.registerInfo("No orphan interior partition surfaces were found")
end
# find and remove orphan LifeCycleCost objects
lcc_objects = model.getObjectsByType("OS:LifeCycleCost".to_IddObjectType)
#make an array to store the names of the orphan LifeCycleCost objects
orphaned_lcc_objects = Array.new
#loop through all LifeCycleCost objects, checking for missing Item Name
lcc_objects.each do |lcc_object|
if lcc_object.isEmpty(4)
orphaned_lcc_objects << lcc_object.handle
puts "**(removing object)#{lcc_object.name} is not connected to any model object"
runner.registerInfo("Removing orphan lifecycle cost named #{lcc_object.name}")
lcc_object.remove
end
end
#summarize the results
if not orphaned_lcc_objects.length > 0
runner.registerInfo("no orphaned LifeCycleCost objects were found")
end
# todo - remove surfaces that would trigger error in E+ (less than 3 vertices or too small.)
# todo - remove empty shading and interior partition groups. Don't think we would want to do this to spaces, since they may contain space types or loads
# remove unused space types
if remove_unused_space_types
unused_flag_counter = 0
model.getSpaceTypes.sort.each do |resource|
if resource.spaces.size == 0
unused_flag_counter += 1
resource.remove
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused space types")
end
# remove unused load defs
if remove_unused_load_defs
unused_flag_counter = 0
model.getSpaceLoadDefinitions.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused load definitions")
end
# remove unused default schedule sets
if remove_unused_schedules
unused_flag_counter = 0
model.getDefaultScheduleSets.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused default schedules sets")
end
# remove unused default schedules
if remove_unused_schedules
unused_flag_counter = 0
model.getSchedules.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused schedules")
end
# remove unused default schedule sets
if remove_unused_constructions
unused_flag_counter = 0
model.getDefaultConstructionSets.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused default construction sets")
# remove default surface and sub surface constructions, but dont' report
# these are typically hidden from users and reporting it may be more confusing that helpful
unused_flag_counter = 0
model.getDefaultSurfaceConstructionss.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
#runner.registerInfo("Removed #{unused_flag_counter} unused default surface constructions")
unused_flag_counter = 0
model.getDefaultSubSurfaceConstructionss.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
#runner.registerInfo("Removed #{unused_flag_counter} unused default sub surface constructions")
# remove default constructions
unused_flag_counter = 0
model.getConstructions.sort.each do |resource|
if resource.directUseCount == 1 # still don't understand why this is 1 not 0
unused_flag_counter += 1
resource.remove
else # this was just put in for testing ot understand why directUseCount isn't 0
#puts ""
#puts "Name #{resource.name}"
#puts "directUseCount = #{resource.nonResourceObjectUseCount}"
#puts "nonResourceObjectUseCount = #{resource.nonResourceObjectUseCount}"
#puts "targets.size = #{resource.targets.size}"
#puts "sources.size = #{resource.sources.size}"
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused constructions")
# remove unused materials
unused_flag_counter = 0
model.getMaterials.sort.each do |resource|
if resource.directUseCount == 0
unused_flag_counter += 1
resource.remove
end
end
runner.registerInfo("Removed #{unused_flag_counter} unused materials")
end
# report final condition of model
runner.registerFinalCondition("The model finished with #{model.numObjects.to_s} objects.")
return true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def measure; end",
"def measure=(_arg0); end",
"def measure\n\t\t1\n\tend",
"def measure(*args, &b)\n end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def called\n self.measurement.called\n end",
"def measure\n start = Time.now\n yield\n Time.now - start\n end",
"def measure\n start = Time.now\n yield\n Time.now - start\n end",
"def measure\n Measure.new(1, self)\n end",
"def measurement(n)\n @options[:before_hook].call(n)\n measure = measure(n, &@options[:fn])\n @options[:after_hook].call(n)\n measure\n end",
"def measure\n Measure.new(@counter+=1)\n end",
"def communicate_measure_result(_ = nil, _ = nil)\r\n end",
"def benchmark\nend",
"def calculated; end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def run()\n\t\tputs \"#{@name} ran for #{@meters} meters in #{self.getTimeLapse} seconds\"\n\t\t# chiama funzione per stampare quante volte ha respirato\n\t\tself.breathe\n\tend",
"def runs; end",
"def statistics; end",
"def medical_use; end",
"def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if call_measurement_enabled? && above_threshold?\n self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0)\n end\n\n retval\n end",
"def stats; end",
"def stats; end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n\n \n \n # Check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n # Find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n\n # Make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n # Copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n new_sch.setName(\"#{new_sch.name.get} with occ sensor\")\n # Reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n end\n \n # Replace the old schedules with the new, reduced schedules\n spaces_sensors_added_to = []\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n \n # Report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the building.\")\n return true\n end \n \n # Report final condition\n runner.registerFinalCondition(\"Added occupancy sensors to #{num_sensors_added} spaces in the building.\")\n\n return true\n\n end",
"def run\n\t\t\tsummary\n\t\tend",
"def quick_stats\n\tend",
"def stats\n \n end",
"def benchmark(reporter); end",
"def stats\n end",
"def stats\n end",
"def measure(name, &block)\n if self.running? name\n yield\n else\n result = nil\n self.results[name] ||= 0\n self.running << name\n self.results[name] += Benchmark.measure{result = yield}.real\n self.running.delete(name)\n result\n end\n end",
"def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if above_threshold?\n self.class.gitlab_method_call_duration_seconds.observe(@transaction.labels.merge(labels), real_time)\n end\n\n retval\n end",
"def measure_code(model,runner)\n measure_folder = \"#{File.dirname(__FILE__)}/\"\n baseline_spreadsheet = \"#{File.dirname(__FILE__)}/baseline.csv\"\n #Note: place output folder locally to run faster! (e.g. your C drive)\n output_folder = \"#{File.dirname(__FILE__)}/tests/output\"\n create_models = true\n simulate_models = true\n create_annual_outputs = true\n create_hourly_outputs = true\n #This creates the measures object and collects all the csv information for the\n # measure_id variant.\n csv_measures = BTAP::Measures::CSV_OS_Measures.new(\n baseline_spreadsheet,\n measure_folder#script root folder where all the csv relative paths are used.\n )\n csv_measures.create_cold_lake_vintages(output_folder) unless create_models == false\n BTAP::SimManager::simulate_all_files_in_folder(output_folder) unless simulate_models == false\n BTAP::Reporting::get_all_annual_results_from_runmanger(output_folder) unless create_annual_outputs == false\n #convert eso to csv then create terminus file.\n BTAP::FileIO::convert_all_eso_to_csv(output_folder, output_folder).each {|csvfile| BTAP::FileIO::terminus_hourly_output(csvfile)} unless create_hourly_outputs == false\n\n end",
"def cpu_metrics\n super\n end",
"def instrument; end",
"def profiler; end",
"def profiler; end",
"def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\t@runner.setLastOpenStudioModel(@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\t@runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end",
"def monitor(*args, &bl)\n result = nil\n took = Benchmark.realtime {\n result = bl.call\n }\n Tools.info(args, op_took: took)\n result\n end",
"def measure_code(model,runner)\n ################ Start Measure code here ################################\n \n #Check weather directory Weather File\n unless (Pathname.new @lib_directory).absolute?\n @lib_directory = File.expand_path(File.join(File.dirname(__FILE__), @lib_directory))\n end\n lib_file = File.join(@lib_directory, @lib_file_name)\n if File.exists?(lib_file) and @lib_file_name.downcase.include? \".osm\"\n BTAP::runner_register(\"Info\",\"#{@lib_file_name} Found!.\", runner)\n else\n BTAP::runner_register(\"Error\",\"#{lib_file} does not exist or is not an .osm file.\", runner)\n return false\n end\n \n #load model and test.\n construction_set = BTAP::Resources::Envelope::ConstructionSets::get_construction_set_from_library( lib_file, @construction_set_name )\n #Set Construction Set.\n unless model.building.get.setDefaultConstructionSet( construction_set.clone( model ).to_DefaultConstructionSet.get )\n BTAP::runner_register(\"Error\",\"Could not set Default Construction #{@construction_set_name} \", runner)\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Default Construction set to #{@construction_set_name} from #{lib_file}\",runner)\n ##########################################################################\n return true\n end",
"def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n # use the built-in error checking \n if !runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n # Report that this is an anti-measure\n runner.registerValue('anti_measure',true) \n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n\t# Initialize counter variables\n\tno_economizer = 0\n\tfixed_dry_bulb = 0\n\tdifferential_dry_bulb = 0\t\n\tfixed_enthalpy = 0\n\tdifferential_enthalpy = 0\n\tfixed_dew_point_and_dry_bulb = 0\n\telectronic_enthalpy = 0\n\tdifferential_dry_bulb_and_enthalpy = 0\n\t\n\t# Retrieve all Controller:Outdoor air objects in the idf \t\n\toa_controllers = workspace.getObjectsByType(\"Controller:OutdoorAir\".to_IddObjectType)\n\t\n\t# Get the names of each Controller:Outdoor Air object\n\toa_controllers.each do |oa_controller|\n\n\t\toa_controller_name = oa_controller.getString(0).to_s #(0) is field Name\n\t\toa_controller_economizer_control_type = oa_controller.getString(7).to_s #(7) is field Economizer Control Type\n\t\n\t\t# test for presence No economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"NoEconomizer\" # or empty\n\t\t\trunner.registerInfo(\"The Controller:Outdoor air object named #{oa_controller_name} has a disabled airside economizer. Economizer sensor faults will not be added.\")\n\t\t\tno_economizer = no_economizer + 1\n\t\tend\n\t\t\n\t\t# test for presence of differential dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir \n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\tdifferential_dry_bulb = differential_dry_bulb + 1\n\t\t\t# info message\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\t\n\n\t\tend # OA Controller Type DifferentialDryBulb\n\n\t\t# test for presence of fixed dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dry_bulb = fixed_dry_bulb + 1\n\t\t\t\n\t\tend # OA Controller Type = FixedDryBulb \t\t\n\t\t\n\t\t# test for presence of fixed enthalpy economizer controller setting \t\t\t\t\n\t\tif oa_controller_economizer_control_type == \"FixedEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\twworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_enthalpy = fixed_enthalpy + 1\n\t\tend # OA Controller Type = FixedEnthalpy \n\t\t\n\t\t# test for presence of differential enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_enthalpy = differential_enthalpy + 1\n\t\t\t\n\t\tend # OA Controller Type =\"Differential Enthalpy\"\t\t\n\t\t\n\t\n\t\t# test for presence of electronic enthalpy economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"ElectronicEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\telectronic_enthalpy = electronic_enthalpy + 1\n\n\t\tend # OA Controller Type = \"ElectronicEnthalpy\" \t\t\n\t\t\n\t\t# test for presence of fixed dew point and dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDewPointAndDryBulb\" \n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dew_point_and_dry_bulb = fixed_dew_point_and_dry_bulb + 1\n\n\t\tend # OA Controller Type = \"FixedDewPointAndDryBulb\" \n\t\n\t\t# test for presence of differential dry bulb and enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulbAndEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_dry_bulb_and_enthalpy = differential_dry_bulb_and_enthalpy + 1\n\t\tend # OA Controller Type \"DifferentialDryBulbAndEnthalpy\"\n\t\t\n\t\t\t\t\n\tend # end loop through oa controller objects\n\n\t# reporting when N/A condition is appropriate\n\tif fixed_dry_bulb +\tdifferential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb +\telectronic_enthalpy + differential_dry_bulb_and_enthalpy == 0\n\t\trunner.registerAsNotApplicable(\"Measure not applicable because the model contains no OutdoorAir:Controller objects with operable economizers.\")\n\tend \n\t\n\ttotal = fixed_dry_bulb + differential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb + electronic_enthalpy + differential_dry_bulb_and_enthalpy\n\t\n\t# reporting initial condition of model\n\trunner.registerInitialCondition(\"The measure started with #{total} Outdoor Air Controllers configured for operational airside economizers. #{no_economizer} Outdoor Air Controller had the Economizer Contrrol Type set to 'NoEconomizer'.\")\n\t# reporting final condition of model\n\trunner.registerFinalCondition(\"The measure finished by adding outdoor and return air temperature and enthalpy sensor faults to #{total} economizer configurations.\")\n \n return true\n \n end",
"def calculation\n end",
"def monitor; end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n # initialize variables\n affected_space_types = []\n affected_flag = false\n power_tot = 0\n power_tot_new = 0\n control_factor = 0.05 #90.1-2010 Table 9.6.2\n\n # standards space types\n affected_space_types << \"BreakRoom\"\n affected_space_types << \"Conference\"\n affected_space_types << \"Office\"\n affected_space_types << \"Restroom\"\n affected_space_types << \"Stair\"\n\n # get model objects\n space_types = model.getSpaceTypes\n\n # DO STUFF\n #TODO account for zone multipliers?\n space_types.each do |st|\n\n std_spc_typ = st.standardsSpaceType.to_s\n area = st.floorArea\n people = st.getNumberOfPeople(area)\n power = st.getLightingPower(area, people)\n power_tot += power\n\n #calcualte LPD\n lpd_area = power / area\n lpd_people = power / people\n\n affected_space_types.each do |ast|\n\n if ast == std_spc_typ\n\n #calculate adjustment and new power\n power_adj = power * control_factor\n power_new = power - power_adj\n\n lpd_area_new = power_new / area\n lpd_people_new = power_new / people\n\n #set new power\n if st.lightingPowerPerFloorArea.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerFloorArea(lpd_area_new)\n\n lpd_area_ip = OpenStudio.convert(lpd_area,\"ft^2\",\"m^2\").get\n lpd_area_new_ip = OpenStudio.convert(lpd_area_new,\"ft^2\",\"m^2\").get\n lpd_area_change = (1 - (lpd_area_new / lpd_area)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_area_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_area_new_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_area_change.round(0)}%\")\n\n elsif st.lightingPowerPerPerson.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerPerson(lpd_people_new)\n\n lpd_people_change = (1 - (lpd_people_new / lpd_people)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_people} W/person\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_people_new} W/person\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_people_change.round(0)}%\")\n\n else\n\n runner.registerWarning(\"Lighting power is specified using Lighting Level (W) for affected space type: #{st.name}\")\n\n end #set new power\n\n affected_flag = true\n\n end\n\n end #affected space types\n\n # calculate new total lighting power\n power = st.getLightingPower(area, people)\n power_tot_new += power\n\n end #space types\n\n # report not applicable\n if affected_flag == false\n runner.registerAsNotApplicable(\"No affected space types found\")\n end\n\n # report initial condition\n runner.registerInitialCondition(\"Total interior lighting power = #{power_tot.round(0)} W\")\n\n # report final condition\n runner.registerFinalCondition(\"Total interior lighting power = #{power_tot_new.round(0)} W\")\n\n return true\n\n end",
"def measure key,value\n @context= {}\n @path = \"#{key}\" \n @context[:callcount] = 1\n @context[:firsttimestampoffset] = Time.now.to_f*1000 - value\n @context[:name] = @path\n @context[:responsetime] = value\n @context_list << @context\n end",
"def total_time=(_arg0); end",
"def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n #use the built-in error checking \n if not runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n require 'json'\n \n # Get the last openstudio model\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\n return false\n end\n model = model.get\n \n results = {}\n \n #get all DX coils in model\n dx_single = workspace.getObjectsByType(\"Coil:Cooling:DX:SingleSpeed\".to_IddObjectType)\n dx_two = workspace.getObjectsByType(\"Coil:Cooling:DX:TwoSpeed\".to_IddObjectType)\n \n dx_single.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial COP: #{dx.getDouble(4).get}\")\n dx.setDouble(4,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final COP: #{dx.getDouble(4).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n\n dx_two.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial High COP: #{dx.getDouble(4).get}, Initial Low COP: #{dx.getDouble(16).get}\")\n dx.setDouble(4,7.62)\n dx.setDouble(16,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final High COP: #{dx.getDouble(4).get}, Final Low COP: #{dx.getDouble(16).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n end\n \n #save airloop parsing results to ems_results.json\n runner.registerInfo(\"Saving ems_results.json\")\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\n ems_string = \"\"\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n return true\n end\n \n timeStep = model.getTimestep.numberOfTimestepsPerHour\n \n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\n #start making the EMS code\n ems_string = \"\" #clear out the ems_string\n ems_string << \"\\n\" \n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\n ems_string << \"\\n\" \n \n results.each_with_index do |(key, value), i| \n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"Schedule:Constant,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\n ems_string << \" Schedule:Constant,\" + \"\\n\"\n ems_string << \" Schedule Value;\" + \"\\n\"\n ems_string << \"\\n\" \n end\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\n ems_string << \"\\n\"\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\n results.each_with_index do |(key, value), i|\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\n end \n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\n \n #save EMS snippet\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n \n #unique initial conditions based on\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\n\n #reporting final condition of model\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\n \n ems_path = '../MembraneHeatPumpCoolingOnly/ems_membrane_heat_pump_cooling_only.ems'\n json_path = '../MembraneHeatPumpCoolingOnly/ems_results.json'\n if File.exist? ems_path\n ems_string = File.read(ems_path)\n if File.exist? json_path\n json = JSON.parse(File.read(json_path))\n end\n else\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\n ems_path1 = ems_path2[0]\n json_path2 = Dir.glob('../../**/ems_results.json')\n json_path1 = json_path2[0]\n if ems_path2.size > 1\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\n end\n if !ems_path1.nil? \n if File.exist? ems_path1\n ems_string = File.read(ems_path1)\n if File.exist? json_path1\n json = JSON.parse(File.read(json_path1))\n else\n runner.registerError(\"ems_results.json file not located\") \n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \n end\n end\n if json.nil?\n runner.registerError(\"ems_results.json file not located\")\n return false\n end\n \n if json.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n return true\n end\n \n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\n runner.registerInfo(\"Adding EMS code to workspace\")\n workspace.addObjects(idf_file.objects)\n \n return true\n\n end",
"def apply_measure_to_model(test_name, args, model_name = nil, result_value = 'Success', warnings_count = 0, info_count = nil)\n # create an instance of the measure\n measure = ChangeBuildingLocation.new\n\n # create an instance of a runner with OSW\n osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')\n osw = OpenStudio::WorkflowJSON.load(osw_path).get\n runner = OpenStudio::Measure::OSRunner.new(osw)\n\n # get model\n if model_name.nil?\n # make an empty model\n model = OpenStudio::Model::Model.new\n else\n # load the test model\n translator = OpenStudio::OSVersion::VersionTranslator.new\n path = OpenStudio::Path.new(File.dirname(__FILE__) + '/' + model_name)\n model = translator.loadModel(path)\n assert(!model.empty?)\n model = model.get\n end\n\n # get arguments\n arguments = measure.arguments(model)\n argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)\n\n # populate argument with specified hash value if specified\n arguments.each do |arg|\n temp_arg_var = arg.clone\n if args.key?(arg.name)\n assert(temp_arg_var.setValue(args[arg.name]))\n end\n argument_map[arg.name] = temp_arg_var\n end\n\n # temporarily change directory to the run directory and run the measure (because of sizing run)\n start_dir = Dir.pwd\n begin\n unless Dir.exist?(run_dir(test_name))\n Dir.mkdir(run_dir(test_name))\n end\n Dir.chdir(run_dir(test_name))\n\n # run the measure\n measure.run(model, runner, argument_map)\n result = runner.result\n ensure\n Dir.chdir(start_dir)\n\n # delete sizing run dir\n FileUtils.rm_rf(run_dir(test_name))\n end\n\n # show the output\n puts \"measure results for #{test_name}\"\n show_output(result)\n\n # assert that it ran correctly\n if result_value.nil? then result_value = 'Success' end\n assert_equal(result_value, result.value.valueName)\n\n # check count of warning and info messages\n unless info_count.nil? then assert(result.info.size == info_count) end\n unless warnings_count.nil? then assert(result.warnings.size == warnings_count) end\n\n # if 'Fail' passed in make sure at least one error message (while not typical there may be more than one message)\n if result_value == 'Fail' then assert(result.errors.size >= 1) end\n\n # save the model to test output directory\n output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/output/#{test_name}_test_output.osm\")\n model.save(output_file_path, true)\n end",
"def measure_code(model,runner)\n ################ Start Measure code here ################################\n # Argument will be passed as instance variable. So if your argument was height, your can access it using @height. \n\n # report initial condition\n site = model.getSite\n initial_design_days = model.getDesignDays\n if site.weatherFile.is_initialized\n weather = site.weatherFile.get\n runner.registerInitialCondition(\"The initial weather file path was '#{weather.path.get}' and the model had #{initial_design_days.size} design days.\")\n else\n runner.registerInitialCondition(\"The initial weather file has not been set and the model had #{initial_design_days.size} design days.\")\n end\n\n\n #Check form weather directory Weather File\n unless (Pathname.new @weather_directory).absolute?\n @weather_directory = File.expand_path(File.join(File.dirname(__FILE__), @weather_directory))\n end\n weather_file = File.join(@weather_directory, @weather_file_name)\n if File.exists?(weather_file) and @weather_file_name.downcase.include? \".epw\"\n BTAP::runner_register(\"Info\", \"The epw weather file #{weather_file} was found!\", runner)\n else\n BTAP::runner_register(\"Error\",\"'#{weather_file}' does not exist or is not an .epw file.\", runner)\n return false\n end\n\n begin\n weather = BTAP::Environment::WeatherFile.new(weather_file)\n #Set Weather file to model.\n weather.set_weather_file(model)\n #Store information about this run in the runner for output. This will be in the csv and R dumps.\n runner.registerValue( 'city',weather.city )\n runner.registerValue( 'state_province_region ',weather.state_province_region )\n runner.registerValue( 'country',weather.country )\n runner.registerValue( 'hdd18',weather.hdd18 )\n runner.registerValue( 'cdd18',weather.cdd18 )\n runner.registerValue( 'necb_climate_zone',BTAP::Compliance::NECB2011::get_climate_zone_name(weather.hdd18).to_s)\n runner.registerFinalCondition( \"Model ended with weatherfile of #{model.getSite.weatherFile.get.path.get}\" )\n rescue\n BTAP::runner_register(\"Error\",\"'#{weather_file}' could not be loaded into model.\", runner)\n\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Weather file set to #{weather_file}\",runner)\n return true\n end",
"def run(workspace, runner, user_arguments)\r\n super(workspace, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(workspace), user_arguments)\r\n return false\r\n end\r\n \r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n # Get the last openstudio model\r\n model = runner.lastOpenStudioModel\r\n if model.empty?\r\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\r\n return false\r\n end\r\n model = model.get\r\n \r\n results = {}\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(7.62))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(7.62)\r\n dx.setRatedLowSpeedCOP(7.62)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #save airloop parsing results to ems_results.json\r\n runner.registerInfo(\"Saving ems_results.json\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\r\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\r\n ems_string = \"\"\r\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n return true\r\n end\r\n \r\n timeStep = model.getTimestep.numberOfTimestepsPerHour\r\n \r\n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\r\n #start making the EMS code\r\n ems_string = \"\" #clear out the ems_string\r\n ems_string << \"\\n\" \r\n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n \r\n results.each_with_index do |(key, value), i| \r\n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\r\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\r\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\r\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\r\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\r\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\r\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\r\n ems_string << \" Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" Schedule Value;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n end\r\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\r\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\r\n ems_string << \"\\n\"\r\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\r\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\r\n results.each_with_index do |(key, value), i|\r\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\r\n end \r\n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\r\n \r\n #save EMS snippet\r\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\r\n \r\n ems_path = '../MembraneHeatPumpCoolingOnlyEms/ems_membrane_heat_pump_cooling_only.ems'\r\n json_path = '../MembraneHeatPumpCoolingOnlyEms/ems_results.json'\r\n if File.exist? ems_path\r\n ems_string = File.read(ems_path)\r\n if File.exist? json_path\r\n json = JSON.parse(File.read(json_path))\r\n end\r\n else\r\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\r\n ems_path1 = ems_path2[0]\r\n json_path2 = Dir.glob('../../**/ems_results.json')\r\n json_path1 = json_path2[0]\r\n if ems_path2.size > 1\r\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\r\n end\r\n if !ems_path1.nil? \r\n if File.exist? ems_path1\r\n ems_string = File.read(ems_path1)\r\n if File.exist? json_path1\r\n json = JSON.parse(File.read(json_path1))\r\n else\r\n runner.registerError(\"ems_results.json file not located\") \r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \r\n end\r\n end\r\n if json.nil?\r\n runner.registerError(\"ems_results.json file not located\")\r\n return false\r\n end\r\n \r\n if json.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n return true\r\n end\r\n \r\n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\r\n runner.registerInfo(\"Adding EMS code to workspace\")\r\n workspace.addObjects(idf_file.objects)\r\n \r\n return true\r\n\r\n end",
"def modeler_description\n return 'The measure performs the following functions: (1) IDs all chillers, (2) Locates their performance curves and outputs the data, (3) Adds reporting variables for chiller-related data.'\n end",
"def build_timing; end",
"def measure_gc\n return unless enabled?\n\n @raw_data << { fake: true }\n @total_time += 1.1\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # define if the measure should run to a specific time period or whole day\n apply_to_time = true\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n single_space_type = runner.getDoubleArgumentValue('single_space_type', user_arguments)\n occupied_space_type = runner.getDoubleArgumentValue('occupied_space_type', user_arguments)\n unoccupied_space_type = runner.getDoubleArgumentValue('unoccupied_space_type', user_arguments)\n starttime_winter2 = runner.getStringArgumentValue('starttime_winter2', user_arguments)\n endtime_winter2 = runner.getStringArgumentValue('endtime_winter2', user_arguments)\n starttime_winter1 = runner.getStringArgumentValue('starttime_winter1', user_arguments)\n endtime_winter1 = runner.getStringArgumentValue('endtime_winter1', user_arguments)\n starttime_summer = runner.getStringArgumentValue('starttime_summer', user_arguments)\n endtime_summer = runner.getStringArgumentValue('endtime_summer', user_arguments)\n auto_date = runner.getBoolArgumentValue('auto_date', user_arguments)\n alt_periods = runner.getBoolArgumentValue('alt_periods', user_arguments)\n demo_cost_initial_const=false\n\n winter_start_month1 = 1\n winter_end_month1 = 5\n summer_start_month = 6\n summer_end_month = 9\n winter_start_month2 = 10\n winter_end_month2 = 12\n\n######### GET CLIMATE ZONES ################\n if auto_date\n ashraeClimateZone = ''\n #climateZoneNUmber = ''\n climateZones = model.getClimateZones\n climateZones.climateZones.each do |climateZone|\n if climateZone.institution == 'ASHRAE'\n ashraeClimateZone = climateZone.value\n runner.registerInfo(\"Using ASHRAE Climate zone #{ashraeClimateZone}.\")\n end\n end\n\n if ashraeClimateZone == '' # should this be not applicable or error?\n runner.registerError(\"Please assign an ASHRAE Climate Zone to your model using the site tab in the OpenStudio application. The measure can't make AEDG recommendations without this information.\")\n return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # else\n # climateZoneNumber = ashraeClimateZone.split(//).first\n end\n # #runner.registerInfo(\"CLIMATE ZONE #{ashraeClimateZone}. Right now does not do anything.\")\n # if !['1', '2', '3', '4', '5', '6', '7', '8'].include? climateZoneNumber\n # runner.registerError('ASHRAE climate zone number is not within expected range of 1 to 8.')\n # return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # end\n\n if alt_periods\n if ashraeClimateZone == '3A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '14:01:00'\n endtime_summer = '17:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '13:01:00'\n endtime_summer = '16:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n end\n else\n if ashraeClimateZone == '2A'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '2B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3A'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3B'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '19:01:00'\n endtime_winter1 = '22:59:00'\n starttime_winter2 = '19:01:00'\n endtime_winter2 = '22:59:00'\n elsif ashraeClimateZone == '3C'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '12:01:00'\n endtime_summer = '15:59:00'\n starttime_winter1 = '16:01:00'\n endtime_winter1 = '19:59:00'\n starttime_winter2 = '16:01:00'\n endtime_winter2 = '19:59:00'\n elsif ashraeClimateZone == '4B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '20:01:00'\n endtime_summer = '23:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '7A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n end\n end\n end \n\n # check the lighting power reduction percentages and for reasonableness\n if occupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif occupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (occupied_space_type < 1) && (occupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally low.\")\n elsif occupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally high.\")\n elsif occupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if unoccupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif unoccupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (unoccupied_space_type < 1) && (unoccupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally low.\")\n elsif unoccupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally high.\")\n elsif unoccupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if single_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif single_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (single_space_type < 1) && (single_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally low.\")\n elsif single_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally high.\")\n elsif single_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the time periods for reasonableness\n if (starttime_winter1.to_f > endtime_winter1.to_f) && (starttime_winter2.to_f > endtime_winter2.to_f) && (starttime_summer.to_f > endtime_summer.to_f)\n runner.registerError('The end time should be larger than the start time.')\n return false\n end\n\n # check the space_type for reasonableness\n space_type = nil\n if object.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No space type was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_SpaceType.empty?\n space_type = object.get.to_SpaceType.get\n elsif !object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError('Script Error - argument not showing up as space type or building.')\n return false\n end\n end\n\n\n ############################################\n\n # assign the time duration when DR strategy is applied, from shift_time1 to shift_time2, only applied when apply_to_time is ture\n shift_time1 = OpenStudio::Time.new(starttime_winter1)\n shift_time2 = OpenStudio::Time.new(endtime_winter1)\n shift_time3 = OpenStudio::Time.new(0, 24, 0, 0)\n shift_time4 = OpenStudio::Time.new(starttime_summer)\n shift_time5 = OpenStudio::Time.new(endtime_summer)\n shift_time6 = OpenStudio::Time.new(starttime_winter2)\n shift_time7 = OpenStudio::Time.new(endtime_winter2)\n \n \n # get space types in model\n if apply_to_building\n space_types = model.getSpaceTypes\n else\n space_types = []\n space_types << space_type # only run on a single space type\n end\n\n # make a hash of old defs and new equipments and luminaire defs\n cloned_equi_defs = {}\n # loop through space types\n space_types.each do |space_type|\n\n equi_set_schs = {}\n if apply_to_building # measure will be applied differently to space types, based on whether the space type is occupied\n if !space_type.people.empty?\n equipment_power_reduction_percent = 1 - (occupied_space_type/100)\n else\n equipment_power_reduction_percent = 1 - (unoccupied_space_type/100)\n end\n runner.registerInitialCondition(\"Equipment power will be reduced by #{occupied_space_type}% in occupied spaces, and reduced by #{unoccupied_space_type}% in unoccupied spaces\")\n\n else\n equipment_power_reduction_percent = 1 - (single_space_type/100) # measure will be applied evenly to all zones\n runner.registerInitialCondition(\"Equipment power will be reduced by #{single_space_type}% to '#{space_type.name}'.\")\n end\n\n space_type_equipments = space_type.electricEquipment\n space_type_equipments.each do |space_type_equipment|\n #clone of not already in hash\n equi_set_sch = space_type_equipment.schedule\n if !equi_set_sch.empty?\n # clone of not already in hash\n if equi_set_schs.key?(equi_set_sch.get.name.to_s)\n new_equi_set_sch = equi_set_schs[equi_set_sch.get.name.to_s]\n else\n new_equi_set_sch = equi_set_sch.get.clone(model)\n new_equi_set_sch = new_equi_set_sch.to_Schedule.get\n new_equi_set_sch_name = new_equi_set_sch.setName(\"#{new_equi_set_sch.name} adjusted #{equipment_power_reduction_percent}\")\n # add to the hash\n equi_set_schs[new_equi_set_sch.name.to_s] = new_equi_set_sch\n end\n # hook up clone to equipment\n \n if space_type_equipment.name.to_s != \"OfficeLarge Data Center Elec Equip\" && space_type_equipment.name.to_s != \"OfficeLarge Main Data Center Elec Equip\"\n space_type_equipment.setSchedule(new_equi_set_sch)\n runner.registerInfo(\"#{space_type_equipment.name} has a new electric equipment schedule\")\n end\n else\n runner.registerWarning(\"#{space_type.equipments.name} doesn't have a schedule.\")\n end\n end\n \n if apply_to_time\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time1} to #{shift_time2}.\")\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time4} to #{shift_time5} during special between month #{summer_start_month} and #{summer_end_month}\")\n else\n runner.registerFinalCondition(\" equipment power is reduced all day.\")\n end\n\n \n # make equipment schedule adjustments and rename.\n equi_set_schs.each do |k, v| # old name and new object for schedule\n if !v.to_ScheduleRuleset.empty?\n\n schedule = v.to_ScheduleRuleset.get\n default_rule = schedule.defaultDaySchedule\n rules = schedule.scheduleRules\n\n days_covered = Array.new(7, false)\n\n if rules.length > 0\n rules.each do |rule|\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = rule.clone(model).to_ScheduleRule.get\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = rule.daySchedule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = rule #rule.clone(model).to_ScheduleRule.get\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n\n cloned_day_winter = rule.daySchedule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n end\n #runner.registerInfo(\"BEFORE #{days_covered}\")\n if days_covered.include?(false)\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = OpenStudio::Model::ScheduleRule.new(schedule)\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n coverSomeDays(summer_rule, days_covered)\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = default_rule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = summer_rule.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n #coverSomeDays(winter_rule1, days_covered)\n #allDaysCovered(summer_rule, days_covered)\n\n cloned_day_winter = default_rule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n\n\n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n #runner.registerInfo(\"AFTER Summer #{days_covered}\")\n else\n runner.registerWarning(\"Schedule '#{k}' isn't a ScheduleRuleset object and won't be altered by this measure.\")\n v.remove # remove un-used clone\n end\n end\n\n end\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the occ sensors will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n material_and_installation_cost_per_space = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_space\",user_arguments)\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n #find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n if apply_to_building #apply to the whole building\n \n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n end\n end\n \n #make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n #TODO skip non-schedule-ruleset schedules\n \n #copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n #reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n #runner.registerInfo(\"***\")\n end\n \n #replace the old schedules with the new schedules\n spaces_sensors_added_to = []\n if apply_to_building #apply to the whole building\n runner.registerInfo(\"Adding occupancy sensors to whole building\")\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n runner.registerInfo(\"Adding occupancy sensors to space type '#{space_type.name}'\")\n space_type.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n runner.registerInfo(\"Adding occupancy sensors to space '#{space.name}\")\n space.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end \n end\n end \n \n #report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the specified areas of the building.\")\n return true\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has several areas where occupancy sensors could be used to reduce lighting energy by turning off the lights while no occupants are present.\") \n \n #add cost of adding occ sensors\n if material_and_installation_cost_per_space != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add #{material_and_installation_cost_per_space} Occ Sensors to the Building\", model.getBuilding, material_and_installation_cost_per_space * num_sensors_added, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n else\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} #{space_type.name} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n end\n \n return true\n \n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n results = {}\r\n dx_name = []\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n dx_heat = model.getCoilHeatingDXSingleSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(6.0))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(6.0)\r\n dx.setRatedLowSpeedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_heat.empty?\r\n dx_heat.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP}\")\r\n dx.setRatedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n \r\n if dx_name.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{dx_name.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The COP of the following coils was increased to 6: #{dx_name}\")\r\n return true\r\n\r\n end",
"def around_perform_stats(*args)\n start = Time.now\n yield\n time_taken = Time.now - start\n statsd.timing(\"duration:#{self}\", time_taken)\n statsd.increment(\"total_successful:#{self}\")\n statsd.increment(\"total_successful\")\n run_hooks(:duration, :duration, args) {|key| statsd.timing(key, time_taken)}\n end",
"def defMeasurement(name,&block)\n mp = {:mp => name, :fields => []}\n @fields = []\n # call the block with ourserlves to process its 'defMetric' statements\n block.call(self) if block\n @fields.each { |f| mp[:fields] << f }\n define_measurement_point(mp)\n end",
"def measure(heading)\n start_time = Time.now\n print heading\n result = yield\n end_time = Time.now - start_time\n puts \" (#{end_time} s)\"\n result\nend",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def record_measure(label)\n $logger.debug(\n tms = Benchmark.measure(label) do\n yield\n end.format(\"%n: %10.6rreal %10.6u user %10.6y sys\")\n )\nend",
"def run_examination\n true\n end",
"def update\n if @clock1_measure.nil?\n discipline_freq\n else\n elapsed = @clock1.time - @clock1_measure.local_time\n discipline_freq if elapsed > @frequency_discipline_interval\n end\n if @clock2_measure.nil?\n discipline_phase\n else\n elapsed = @clock2.time - @clock2_measure.local_time\n discipline_phase if elapsed > @phase_discipline_interval\n end\n end",
"def benchmark!\n @benchmark = true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n pct_red = runner.getDoubleArgumentValue(\"pct_red\",user_arguments)\n start_hr = runner.getDoubleArgumentValue(\"start_hr\",user_arguments)\n end_hr = runner.getDoubleArgumentValue(\"end_hr\",user_arguments)\n \n\n\n #check the fraction for reasonableness\n if not 0 <= pct_red and pct_red <= 100\n runner.registerError(\"Percent reduction value needs to be between 0 and 100.\")\n return false\n end\n\n #check start_hr for reasonableness and round to 15 minutes\n start_red_hr = nil\n start_red_min = nil\n if not 0 <= start_hr and start_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24\")\n return false\n else\n rounded_start_hr = ((start_hr*4).round)/4.0\n if not start_hr == rounded_start_hr\n runner.registerInfo(\"Start time rounded to nearest 15 minutes: #{rounded_start_hr}\")\n end\n start_red_hr = rounded_start_hr.truncate\n start_red_min = (rounded_start_hr - start_red_hr)*60\n start_red_min = start_red_min.to_i\n end\n\n #check end_hr for reasonableness and round to 15 minutes\n end_red_hr = nil\n end_red_min = nil \n if not 0 <= end_hr and end_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_hr > end_hr\n runner.registerError(\"Please enter an end time later in the day than end time.\")\n return false\n else\n rounded_end_hr = ((end_hr*4).round)/4.0\n if not end_hr == rounded_end_hr\n runner.registerInfo(\"End time rounded to nearest 15 minutes: #{rounded_end_hr}\")\n end\n end_red_hr = rounded_end_hr.truncate\n end_red_min = (rounded_end_hr - end_red_hr)*60\n end_red_min = end_red_min.to_i\n end\n\n # Translate the percent reduction into a multiplier\n red_mult = pct_red/100\n\n # Get schedules from all lights.\n original_lights_schs = []\n model.getLightss.each do |lights|\n if lights.schedule.is_initialized\n lights_sch = lights.schedule.get\n original_lights_schs << lights_sch\n end\n end\n\n # loop through the unique list of lights schedules, cloning\n # and reducing schedule fraction during the specified time range.\n original_lights_schs_new_schs = {}\n original_lights_schs.uniq.each do |lights_sch|\n if lights_sch.to_ScheduleRuleset.is_initialized\n new_lights_sch = lights_sch.clone(model).to_ScheduleRuleset.get\n new_lights_sch.setName(\"#{lights_sch.name} with Solar Cogeneration and Daylighting\")\n original_lights_schs_new_schs[lights_sch] = new_lights_sch\n new_lights_sch = new_lights_sch.to_ScheduleRuleset.get\n \n # method to adjust the values in a day schedule by a \n # specified percentage during a range of hours.\n def reduce_schedule(day_sch, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n start_time = OpenStudio::Time.new(0, start_red_hr, start_red_min, 0)\n end_time = OpenStudio::Time.new(0, end_red_hr, end_red_min, 0)\n\n # Get the original values at the desired start and end times\n # and put points into the schedule at those times.\n day_sch.addValue(start_time, day_sch.getValue(start_time))\n day_sch.addValue(end_time, day_sch.getValue(end_time))\n \n # Store the original time/values then clear the schedule\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n # Modify the time/values and add back to the schedule\n for i in 0..(values.length - 1)\n if times[i] > start_time and times[i] <= end_time # Inside range\n day_sch.addValue(times[i], values[i] * red_mult)\n else\n day_sch.addValue(times[i], values[i])\n end\n end\n\n end #end reduce schedule\n\n # Reduce default day schedule\n if new_lights_sch.scheduleRules.size == 0\n runner.registerWarning(\"Schedule '#{new_lights_sch.name}' applies to all days. It has been treated as a Weekday schedule.\")\n end\n reduce_schedule(new_lights_sch.defaultDaySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n \n # Reduce all other schedule rules\n new_lights_sch.scheduleRules.each do |sch_rule|\n reduce_schedule(sch_rule.daySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n end\n \n end \n end #end of original_lights_schs.uniq.each do\n\n #loop through all lights instances, replacing old lights schedules with the reduced schedules\n model.getLightss.each do |lights|\n if lights.schedule.empty?\n runner.registerWarning(\"There was no schedule assigned for the lights object named '#{lights.name}. No schedule was added.'\")\n else\n old_lights_sch = lights.schedule.get\n lights.setSchedule(original_lights_schs_new_schs[old_lights_sch])\n runner.registerInfo(\"Schedule for the lights object named '#{lights.name}' was reduced to simulate the application of Solar Cogeneration and Daylighting.\")\n end\n end\n\n # NA if the model has no lights\n if model.getLightss.size == 0\n runner.registerNotAsApplicable(\"Not Applicable - There are no lights in the model.\")\n end\n\n # Reporting final condition of model\n runner.registerFinalCondition(\"#{original_lights_schs.uniq.size} schedule(s) were edited to reflect the addition of Solar Cogeneration and Daylighting to the building.\")\n \n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n\n\t#initialize variables\n\ttz_count = 0\n\tclg_tstat_schedule = []\n\tthermal_zone_array = []\n\t\t\n\t# get the thermal zones and loop through them \n\tmodel.getThermalZones.each do |thermal_zone|\n\t\n\t\tthermal_zone_array << thermal_zone\n\t\t\n\t\t# test to see if thermal zone has a thermostat object assigned or is unconditioned. \n\t\tif thermal_zone.thermostatSetpointDualSetpoint.is_initialized\n\t\t\tzone_thermostat = thermal_zone.thermostatSetpointDualSetpoint.get\n\t\t\ttz_count += 1\n\t\t\t\n\t\t\tif zone_thermostat.coolingSetpointTemperatureSchedule.is_initialized\n\t\t\t\tclg_tstat_schedule = zone_thermostat.coolingSetpointTemperatureSchedule.get\n\t\t\t\t\n\t\t\t\t# clone the existing cooling T-stat schedule in case it is used somewhere else in the model\n\t\t\t\tcloned_clg_tstat_schedule = clg_tstat_schedule.clone\n\t\t\t\t@new_clg_tstat_schedule_name = (\"#{clg_tstat_schedule.name}+1.5F\")\n\t\t\t\n\t\t\t\tif cloned_clg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_clg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles = []\n\t\t\t\t\tcooling_thermostat_array = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\n\t\t\t\t\tprofiles << defaultProfile\n\t\t\t\t\trules = schedule.scheduleRules\n\t\t\t\t\n\t\t\t\t\trules.each do |rule|\n\t\t\t\t\t\tprofiles << rule.daySchedule\n\t\t\t\t\tend # end the do loop through the rulesetsdo\n\n\t\t\t\t\t#adjust profiles of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles.each do |profile|\n\t\t\t\t\t\ttime = profile.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile.values.each do |value|\n\t\t\t\t\t\t\tdelta = 0.8333\n\t\t\t\t\t\t\tnew_value = value + delta # Note this is where the cooling setpoint is raised\n\t\t\t\t\t\t\tprofile.addValue(time[i], new_value)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\t\tcloned_clg_tstat_schedule.setName(@new_clg_tstat_schedule_name)\n\t\t\t\t\t\t\tcooling_thermostat_array << cloned_clg_tstat_schedule\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setCoolingSetpointTemperatureSchedule(cloned_clg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing cooling thermostat '#{clg_tstat_schedule.name}' has been changed to #{cloned_clg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying cooling tstat schedule object\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a cooling setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for cooling Setpoint Temperature is initialized\n\t\t\t\n\t\t\tif zone_thermostat.heatingSetpointTemperatureSchedule.is_initialized\n\t\t\t\thtg_tstat_schedule = zone_thermostat.heatingSetpointTemperatureSchedule.get\n\t\t\t\t\t\t\n\t\t\t\t# clone the existing heating T-stat schedule in case it is used somewhere else\n\t\t\t\tcloned_htg_tstat_schedule = htg_tstat_schedule.clone\n\t\t\t\t\n\t\t\t\t#name cloned heating t-stat schedule\n\t\t\t\tcloned_htg_tstat_schedule.setName(\"#{htg_tstat_schedule.name}-1.5F\")\n\n\t\t\t\tif cloned_htg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_htg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles_h = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\t\n\t\t\t\t\tprofiles_h << defaultProfile\n\t\t\t\t\trules_h = schedule.scheduleRules\n\t\t\t\t\trules_h.each do |rule_h|\n\t\t\t\t\t\tprofiles_h << rule_h.daySchedule\n\t\t\t\t\tend # end the rule_h do\n\n\t\t\t\t\t#adjust profiles_h of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles_h.each do |profile_h|\n\t\t\t\t\t\ttime_h = profile_h.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile_h.values.each do |value_h|\n\t\t\t\t\t\t\tdelta_h = 0.8333\n\t\t\t\t\t\t\tnew_value_h = value_h - delta_h # Note this is where the heating setpoint is lowered \n\t\t\t\t\t\t\tprofile_h.addValue(time_h[i], new_value_h)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile_h\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setHeatingSetpointTemperatureSchedule(cloned_htg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing heating thermostat '#{htg_tstat_schedule.name}' has been changed to #{cloned_htg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying heating tstat schedule object\t\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a heating setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for heating Setpoint Temperature is initialized\n\t\tend\t# end if statement for zone_thermstat cooling schedule\n\t\t\n\tend # end loop through thermal zones\t\t\t\n\t\t\t\n\t# Add ASHRAE 55 Comfort Warnings are applied to people objects\n\t# get people objects and people definitions in model\n\tpeople_defs = model.getPeopleDefinitions\n\tpeople_instances = model.getPeoples\n\n\t# loop through people objects\n\tpeople_def_counter = 0\n\tpeople_defs.sort.each do |people_def|\n\t next if not people_def.instances.size > 0\n\t people_def_counter += 1\n\t people_def.setEnableASHRAE55ComfortWarnings(true)\n\tend\n\t\t\t\n\treporting_frequency = \"Timestep\"\n\toutputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n\toutputVariable.setReportingFrequency(reporting_frequency)\n\trunner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting '#{reporting_frequency}'\")\n\n\t# write As Not Applicable message\n\tif tz_count == 0\n\t\trunner.registerAsNotApplicable(\"Measure is not applicable. There are no conditioned thermal zones in the model.\")\n\t\treturn true\n\tend\n\n\t# report initial condition of model\n\trunner.registerInitialCondition(\"The initial model contained #{tz_count} thermal zones with #{thermal_zone_array.length} 'Cooling Thermostat Schedule' and #{thermal_zone_array.length} 'Heating Thermostat Schedule' objects for which this measure is applicable.\")\n\n\t# report final condition of model\n\trunner.registerFinalCondition(\"The #{thermal_zone_array.length} Heating and #{thermal_zone_array.length} Cooling Thermostats schedules for #{thermal_zone_array.length} Thermal Zones were altered to reflect a additional deadband width of 3 Deg F . \")\n\treturn true\n\n end",
"def stat(*args)\n @recorder.call(*args) if @recorder\n end",
"def measure (n=1)\n cnt=0\nelapsed_time=Time.now\n\nn.times {\n cnt+=1\n yield} \nelapsed_time=(Time.now-elapsed_time)/cnt\n\nend",
"def run() end",
"def running_test_step; end",
"def stat() end",
"def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend",
"def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n #initialize variables\n zone_hvac_count = 0\n pump_count = 0\n air_loop_count = 0\n \n #loop through each air loop in the model\n model.getAirLoopHVACs.sort.each do |air_loop|\n\n # call the method to generate a new occupancy schedule based on a 5% threshold\n occ_sch = air_loop.get_occupancy_schedule(0.15)\n old_sch = air_loop.availabilitySchedule\n next unless compare_eflh(runner, old_sch, occ_sch)\n # set the availability schedule of the airloop to the newly generated schedule\n air_loop.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_sch.name} for #{air_loop.name} was replaced with a new schedule named #{occ_sch.name} which tracks the occupancy profile of the thermal zones on this airloop.\")\n air_loop_count +=1\n \n end\n\n #loop through each thermal zone\n model.getThermalZones.sort.each do |thermal_zone|\n \n # zone equipments assigned to thermal zones\n thermal_zone_equipment = thermal_zone.equipment \n \n if thermal_zone_equipment.size >= 1\n # run schedule method to create a new schedule ruleset, routines \n occ_sch = thermal_zone.get_occupancy_schedule(0.15)\n \n #loop through Zone HVAC Equipment\n thermal_zone_equipment.each do |equip|\n \n # getting the fan exhaust object & getting relevant information for it. \n if equip.to_FanZoneExhaust.is_initialized\n zone_equip = equip.to_FanZoneExhaust.get\n old_schedule = zone_equip.availabilitySchedule.get\n next unless compare_eflh(runner, old_schedule, occ_sch)\n #assign the 'occ_sch' here as exhaust's availability schedule\n zone_equip.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_schedule.name} for the OS_Fan_ZoneExhaust named #{zone_equip.name} was replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\n zone_hvac_count += 1 \t\n elsif equip.to_RefrigerationAirChiller.is_initialized\n zone_equip = equip.to_RefrigerationAirChiller.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_WaterHeaterHeatPump.is_initialized\n zone_equip = equip.to_WaterHeaterHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACDehumidifierDX.is_initialized\n zone_equip = equip.to_ZoneHVACDehumidifierDX.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACEnergyRecoveryVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACEnergyRecoveryVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACFourPipeFanCoil.is_initialized\n zone_equip = equip.to_ZoneHVACFourPipeFanCoil.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACHighTemperatureRadiant.is_initialized\n zone_equip = equip.to_ZoneHVACHighTemperatureRadiant.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACIdealLoadsAirSystem.is_initialized\n zone_equip = equip.to_ZoneHVACIdealLoadsAirSystem.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t \n elsif equip.to_ZoneHVACLowTemperatureRadiantElectric.is_initialized\n zone_equip = equip.to_ZoneHVACLowTemperatureRadiantElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACLowTempRadiantConstFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantConstFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t \t\n elsif equip.to_ZoneHVACLowTempRadiantVarFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantVarFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalAirConditioner.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACPackagedTerminalHeatPump.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.is_initialized\n next unless compare_eflh(runner, old_schedule, occ_sch) \n equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get.setTerminalUnitAvailabilityschedule(occ_sch)\n runner.registerInfo(\"The availability schedule for the Zone HVAC Terminal Unit Variable Refrigerant Flow Object has been replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\t\t\t\t\t\n zone_hvac_count += 1 \n elsif equip.to_ZoneHVACUnitHeater.is_initialized\n zone_equip = equip.to_ZoneHVACUnitHeater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\n elsif equip.to_ZoneHVACUnitVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACUnitVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneVentilationDesignFlowRate.is_initialized\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has a Zone Ventilation Design Flow Rate object attacjhed as a ZoneHVACEquipment object. No modification were made to this object.\")\t\t\n end \t\n \n end # end loop through Zone HVAC Equipment\n \n else\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has no Zone HVAC Equipment objects attached - therefore no schedule objects have been altered.\")\t\n end # end of if statement\n \n end # end loop through thermal zones\n\n # Change pump control status if any airloops or\n # zone equipment were changed.\n if air_loop_count > 0 || zone_hvac_count > 0\n model.getPlantLoops.each do |plantLoop|\n #Loop through each plant loop demand component\n plantLoop.demandComponents.each do |dc|\n if dc.to_PumpConstantSpeed.is_initialized\n cs_pump = dc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n \n if dc.to_PumpVariableSpeed.is_initialized\n vs_pump = dc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Demand side Pump Control Type attribute of Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n end\n \n #Loop through each plant loop supply component\n plantLoop.supplyComponents.each do |sc|\n if sc.to_PumpConstantSpeed.is_initialized\n cs_pump = sc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Supply Side Pump Control Type atteribute of Constant Speed Pump named #{cs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component constant speed pump objects\n \n if sc.to_PumpVariableSpeed.is_initialized\n vs_pump = sc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Variable Speed Pump object named #{vs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Supply Side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component variable speed pump objects\n \n end # end loop throught plant loop supply side components\n \n end # end loop through plant loops\n end\n \n #Write N/A message\n if air_loop_count == 0 && zone_hvac_count == 0 && pump_count == 0 \n runner.registerAsNotApplicable(\"The model did not contain any Airloops, Thermal Zones having ZoneHVACEquipment objects or associated plant loop pump objects to act upon. The measure is not applicable.\")\n return true\n end\t\n \n #report initial condition of model\n runner.registerInitialCondition(\"The model started with #{air_loop_count} AirLoops, #{zone_hvac_count} Zone HVAC Equipment Object and #{pump_count} pump objects subject to modifications.\")\n \n # report final condition of model\n runner.registerFinalCondition(\"The measure modified the availability schedules of #{air_loop_count} AirLoops and #{zone_hvac_count} Zone HVAC Equipment objects. #{pump_count} pump objects had control settings modified.\")\n \n # Add ASHRAE Standard 55 warnings\n reporting_frequency = \"Timestep\"\n outputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n outputVariable.setReportingFrequency(reporting_frequency)\n runner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting at the model timestep.\")\n \n return true\n\t\n end",
"def calc_next_run\n nil\n end",
"def calc_next_run\n nil\n end",
"def running_test_case; end",
"def estimate\n # (native code) \n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def tick; end",
"def tick; end",
"def tick; end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n fixed_window_subsurface = runner.getOptionalWorkspaceObjectChoiceValue('fixed_window_subsurface', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments) \n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments) \n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n # declare arrys for scope\n array_of_21_sets = []\n material_property_glazing_spectral_data_vector = []\n standard_glazing_layer_array = []\n construction_array = []\n ems_window_construction_array = []\n \n # load idf into workspace\n workspace = OpenStudio::Workspace::load(OpenStudio::Path.new(\"#{File.dirname(__FILE__)}/resources/EMSThermochromicWindow.idf\")).get\n \n # get all MaterialPropertyGlazingSpectralData objects from within the idf\n # material_property_glazing_spectral_datas = source_idf.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n material_property_glazing_spectral_datas = workspace.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n if verbose_info_statements == true\n runner.registerInfo(\"The model has #{material_property_glazing_spectral_datas.size} material_property_glazing_spectral_datas objects.\")\n end\n \n material_property_glazing_spectral_datas.each do |material_property_glazing_spectral_data|\n \n spectral_data = {\"name\" => \"\",\"properties\" => []}\n spectral_data[\"name\"] = material_property_glazing_spectral_data.getString(0).to_s\n \n # Note: EnergyPlus file MaterialProperty:GlazingSpectralData objects have 1764 /4 = 441 sets of 4 values each \n n = material_property_glazing_spectral_data.numFields\n (1..n).each do |i| \n spectral_data[\"properties\"] << material_property_glazing_spectral_data.getString(i).to_s \n end\n array_of_21_sets << spectral_data\n end\n \n array_of_21_sets.each do |set|\n \n props = set[\"properties\"]\n material_property_glazing_spectral_data = OpenStudio::Model::MaterialPropertyGlazingSpectralData.new(model)\n material_property_glazing_spectral_data.setName(\"#{set[\"name\"]}\")\n \n k = (props.length / 4) - 1\n (0..k).each do |i| # note 440 uniques (a, b, c, d) pairs of attributes for each spectral data field object\n material_property_glazing_spectral_data.addSpectralDataField(props[(i*4)+0].to_f, props[(i*4)+1].to_f, props[(i*4)+2].to_f, props[(i*4)+3].to_f)\t\n end\n \n material_property_glazing_spectral_data_vector << material_property_glazing_spectral_data\n end \n \n # create (2) required new air gas materials to used by all EMS window constructions \n air_gas_3mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.003) \n air_gas_3mm_material.setName(\"AIR 3MM\")\n \n air_gas_8mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.008) \n air_gas_8mm_material.setName(\"AIR 8MM\")\n \n # loop through array of OS MaterialPropertyGlazingSpectralData objects and create 21 new Standard Glazing objects \n material_property_glazing_spectral_data_vector.each do |spec_data_obj|\n spec_data_obj_name = spec_data_obj.name\n layer_name = spec_data_obj_name.to_s.slice(\"sp\")\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.0075)\n else\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.003276)\n end\n layer.setName(\"#{layer_name}\")\n layer.setWindowGlassSpectralDataSet(spec_data_obj)\n layer.setInfraredTransmittanceatNormalIncidence(0) # same for all 21 constructions\n layer.setFrontSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n layer.setBackSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer.setConductivity(1.0) \n else\n layer.setConductivity(0.6) \n end\n layer.setDirtCorrectionFactorforSolarandVisibleTransmittance(1) # same for all 21 constructions\n layer.setSolarDiffusing(false)\n standard_glazing_layer_array << layer\n end\n\n # Create (2) unique standard glazing layers not used for Thermochromatic performance \n sb60_clear_3_ppg_layer = standard_glazing_layer_array[0]\n clear_3ppg_layer = standard_glazing_layer_array[1]\n remaining_standard_glazing_layer_array = standard_glazing_layer_array.drop(2)\n \n # create (19) new arrays of layered constructions representing thermochromatic layers\n remaining_standard_glazing_layer_array.each do |remaining_standard_glazing_layer|\n construction = [sb60_clear_3_ppg_layer, air_gas_3mm_material, remaining_standard_glazing_layer, air_gas_8mm_material, sb60_clear_3_ppg_layer]\n construction_array << construction\n end\n \n # create 19 new OS:Construction objects representing EMS thermochromatic windows\n name_index_array = [25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 50, 55, 60, 65, 70, 75, 80, 85]\n index = 0\n \n construction_array.each do |const|\n ems_window_construction = OpenStudio::Model::Construction.new(const)\n ems_window_construction.setName(\"TCwindow_#{name_index_array[index]}\")\n if verbose_info_statements == true\n runner.registerInfo(\"Created a new Construction named #{ems_window_construction.name} representing a thermochromatic window construction.\")\n end\n ems_window_construction_array << ems_window_construction\n index +=1\n end\n\n # check the user argument of the fixed window subsurface for reasonableness\n if fixed_window_subsurface.empty?\n handle = runner.getStringArgumentValue('fixed_window_subsurface', user_arguments)\n if handle.empty?\n runner.registerError('No fixed window subsurface was chosen.')\n else\n runner.registerError(\"The selected fixed window subsurface with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !fixed_window_subsurface.get.to_SubSurface.empty?\n fixed_window_subsurface = fixed_window_subsurface.get.to_SubSurface.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end\n \n # Create a new EnergyManagementSystem:Sensor object representing the Surface Outside Face temp of the EMS thermochromatic window subsurface\n ems_win_Tout_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Surface Outside Face Temperature\")\n ems_win_Tout_sensor.setName(\"Win1_Tout\")\n ems_win_Tout_sensor.setKeyName(\"#{fixed_window_subsurface.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Sensor object named '#{ems_win_Tout_sensor.name}' representing the Surface Outside Face temp of the EMS thermochromatic window subsurface was added to the model.\") \n end\n \n # Create a new EMS Actuator Object representing the construction state of the EMS generated thermochromatic window \n ems_win_construct_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fixed_window_subsurface, \"Surface\", \"Construction State\")\n ems_win_construct_actuator.setName(\"Win1_Construct\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_win_construct_actuator.name}' representing construction state of the EMS generated thermochromatic window was added to the model.\") \n end\n \n # Create 19 EnergyManagementSystem:ConstructionIndexVariable objects for each unique thermochromatic construction\n ems_window_construction_array.each do |ems_window_construction|\n ems_constr_index_var = OpenStudio::Model::EnergyManagementSystemConstructionIndexVariable.new(model, ems_window_construction ) \n ems_constr_index_var.setName(\"#{ems_window_construction.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS SystemConstructionIndexVariable object named '#{ems_constr_index_var.name}' representing the the EMS construction state of the thermochromatic window was added to the model.\") \n end\n end\n \n # Create new EnergyManagementSystem:Program object for assigning different window constructions by dynamically evaluating the exterior surface temp of the fixed window subsurface \n ems_apply_thermochromatic_constructions_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_apply_thermochromatic_constructions_prgm.setName(\"#{fixed_window_subsurface.name}_Control\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"IF #{ems_win_Tout_sensor.name} <= 26.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_25\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 28.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_27\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 30.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_29\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 32.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_31\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 34.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_33\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 36.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_35\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 38.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_37\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 40.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_39\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 42.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_41\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 44.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_43\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 47.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_45\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 52.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_50\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 57.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_55\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 62.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_60\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 67.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_65\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 72.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_70\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 77.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_75\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 82.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_80\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSE\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_85\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ENDIF\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Program Object named '#{ems_apply_thermochromatic_constructions_prgm.name}' for dynamically assigning different window constructions based on the exterior surface temp was added to the model.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"My thermochromic window emulator\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginTimestepBeforePredictor\")\n ems_prgm_calling_mngr.addProgram(ems_apply_thermochromatic_constructions_prgm)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call EMS program for dynamically applying a thermochromatic window.\") \n end\n \n # create unique object for OutputEnergyManagementSystems and configure to allow EMS reporting\n outputEMS = model.getOutputEnergyManagementSystem\n outputEMS.setInternalVariableAvailabilityDictionaryReporting(\"internal_variable_availability_dictionary_reporting\")\n outputEMS.setEMSRuntimeLanguageDebugOutputLevel(\"ems_runtime_language_debug_output_level\")\n outputEMS.setActuatorAvailabilityDictionaryReporting(\"actuator_availability_dictionary_reporting\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS OutputEnergyManagementSystem object configured per user arguments.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def bench(action, msg = nil)\n @t ||= Time.now\n @total ||= 0\n @step ||= 0\n case action\n when :start\n @step = 0\n @total = 0\n @t = Time.now\n when :step\n @step += 1\n int = Time.now - @t\n @total += int\n @t = Time.now\n dbg(\"Benchmark #{msg.nil? ? (\"%02d\" % @step) : msg}: #{\"%8.3fms\" % (int * 1000)} (Total: #{\"%8.3fms\" % (@total * 1000)}).\")\n end\nend",
"def apply_measure_and_run(test_name, measure, argument_map, osm_path, epw_path, run_model: false)\n assert(File.exist?(osm_path))\n assert(File.exist?(epw_path))\n\n # create run directory if it does not exist\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n # change into run directory for tests\n start_dir = Dir.pwd\n Dir.chdir run_dir(test_name)\n\n # remove prior runs if they exist\n if File.exist?(model_output_path(test_name))\n FileUtils.rm(model_output_path(test_name))\n end\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n # copy the osm and epw to the test directory\n new_osm_path = \"#{run_dir(test_name)}/#{File.basename(osm_path)}\"\n FileUtils.cp(osm_path, new_osm_path)\n new_epw_path = \"#{run_dir(test_name)}/#{File.basename(epw_path)}\"\n FileUtils.cp(epw_path, new_epw_path)\n # create an instance of a runner\n runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)\n\n # load the test model\n model = load_model(new_osm_path)\n\n # set model weather file\n epw_file = OpenStudio::EpwFile.new(OpenStudio::Path.new(new_epw_path))\n OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file)\n assert(model.weatherFile.is_initialized)\n\n # run the measure\n puts \"\\nAPPLYING MEASURE...\"\n measure.run(model, runner, argument_map)\n result = runner.result\n\n # show the output\n show_output(result)\n\n # save model\n model.save(model_output_path(test_name), true)\n\n errs = []\n if run_model && (result.value.valueName == 'Success')\n puts \"\\nRUNNING ANNUAL SIMULATION...\"\n\n std = Standard.build('NREL ZNE Ready 2017')\n std.model_run_simulation_and_log_errors(model, run_dir(test_name))\n\n # check that the model ran successfully and generated a report\n assert(File.exist?(model_output_path(test_name)))\n assert(File.exist?(sql_path(test_name)))\n assert(File.exist?(report_path(test_name)))\n\n # set runner variables\n runner.setLastEpwFilePath(epw_path)\n runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_output_path(test_name)))\n runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))\n sql = runner.lastEnergyPlusSqlFile.get\n model.setSqlFile(sql)\n\n # test for unmet hours\n unmet_heating_hrs = std.model_annual_occupied_unmet_heating_hours(model)\n unmet_cooling_hrs = std.model_annual_occupied_unmet_cooling_hours(model)\n unmet_hrs = std.model_annual_occupied_unmet_hours(model)\n max_unmet_hrs = 550\n if unmet_hrs\n if unmet_hrs > 550\n errs << \"For #{test_name} there were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}), more than the limit of #{max_unmet_hrs}.\" if unmet_hrs > max_unmet_hrs\n else\n puts \"There were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}).\"\n end\n else\n errs << \"For #{test_name} could not determine unmet hours; simulation may have failed.\"\n end\n end\n\n # change back directory\n Dir.chdir(start_dir)\n\n assert(errs.empty?, errs.join(\"\\n\"))\n\n return result\n end",
"def after_assumption(name); end",
"def call\n result = while_measuring_memory_usage { action.call }\n\n Measurement.from_result(result)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n retrofit_month = runner.getStringArgumentValue('retrofit_month', user_arguments).to_i\n retrofit_day = runner.getStringArgumentValue('retrofit_day', user_arguments).to_i\n\n # report initial condition of model\n runner.registerInitialCondition(\"Measure started successfully.\")\n\n # TODO: check the month and day for reasonableness\n runner.registerInfo(\"User entered retrofit month: #{retrofit_month}\")\n runner.registerInfo(\"User entered retrofit day: #{retrofit_day}\")\n\n prog_calling_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n prog_calling_manager.setCallingPoint('BeginTimestepBeforePredictor')\n\n # Remove old and add new equip with EMS by spaces\n hash_space_epd = Hash.new\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n current_space_equip = space.electricEquipment[0]\n unless current_space_equip.nil?\n\n # Get equipment power density for each space type\n new_space_epd = runner.getOptionalDoubleArgumentValue(\"new_#{space.name.to_s}_epd\", user_arguments)\n if new_space_epd.is_initialized\n hash_space_epd[\"new_#{space.name.to_s}_epd\"] = new_space_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space.name.to_s} is #{new_space_epd} W/m2\")\n # Set ems\n current_space_equip_def = current_space_equip.electricEquipmentDefinition\n equip_sch_name = current_space_equip.schedule.get.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n runner.registerInfo(\"Delete old equip object for #{space.name}\")\n current_space_equip.remove\n\n new_equip = add_equip_space(space, current_space_equip_def)\n equip_level_w = new_space_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n else\n # Get equipment power ratio for each space type\n new_space_ratio = runner.getDoubleArgumentValue(\"new_#{space.name.to_s}_ratio\", user_arguments)\n\n old_equip_sch = current_space_equip.schedule.get\n ems_equip_program = add_equip_ems_w_occ_var(model, current_space_equip, old_equip_sch, new_space_ratio, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n # runner.registerInfo(\"Delete old equip object for #{space.name}\")\n # current_space_equip.remove\n end\n\n end\n end\n\n # Remove old and add new equip with EMS by space types\n hash_space_type_epd = Hash.new\n v_space_types = model.getSpaceTypes\n v_space_types.each do |space_type|\n current_spaces = space_type.spaces\n current_space_type_equip = space_type.electricEquipment[0]\n unless current_space_type_equip.nil?\n # Get equipment power density for each space type\n current_space_type_epd = runner.getStringArgumentValue(\"new_#{space_type.name.to_s}_epd\", user_arguments)\n hash_space_type_epd[\"new_#{space_type.name.to_s}_epd\"] = current_space_type_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space_type.name.to_s} is #{current_space_type_epd} W/m2\")\n\n # Set ems\n current_space_type_equip_def = current_space_type_equip.electricEquipmentDefinition\n current_space_type_sch_set = space_type.defaultScheduleSet.get\n current_space_type_equip_sch_set = current_space_type_sch_set.electricEquipmentSchedule.get\n\n equip_sch_name = current_space_type_equip_sch_set.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n\n puts \"Delete old equip object for #{space_type.name}\"\n current_space_type_equip.remove\n\n current_spaces.each do |space|\n # Calculate equipemtn electric power for each space\n new_equip = add_equip_space_type(model, space, space_type, current_space_type_equip_def)\n equip_level_w = current_space_type_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n end\n end\n end\n\n # echo the model updates back to the user\n runner.registerInfo(\"The electric equipment retrofit measure is applied.\")\n\n # report final condition of model\n runner.registerFinalCondition(\"Measure ended successfully.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n runner.registerInfo(\"Start to create lighting measure from occupant schedule\")\n\n ### Get user selected lighting space assumptions for each space\n v_space_types = model.getSpaceTypes\n i = 1\n lght_space_type_arg_vals = {}\n # Loop through all space types, group spaces by their types\n v_space_types.each do |space_type|\n # Loop through all spaces of current space type\n v_current_spaces = space_type.spaces\n next if not v_current_spaces.size > 0\n v_current_spaces.each do |current_space|\n lght_space_type_val = runner.getStringArgumentValue(@@v_space_args[current_space.nameString], user_arguments)\n lght_space_type_arg_vals[current_space.nameString] = lght_space_type_val\n i += 1\n end\n end\n\n puts lght_space_type_arg_vals\n\n ### Start creating new lighting schedules based on occupancy schedule\n occ_schedule_dir = runner.getStringArgumentValue('occ_schedule_dir', user_arguments)\n model_temp_run_path = Dir.pwd + '/'\n measure_root_path = File.dirname(__FILE__)\n\n puts '=' * 80\n puts measure_root_path\n\n if File.file?(occ_schedule_dir)\n # Check if user provided a occupancy schedule CSV file\n csv_file = occ_schedule_dir\n puts 'Use user provided occupancy schedule file at: ' + csv_file.to_s\n runner.registerInitialCondition('Location check:' + File.expand_path(\"../..\", measure_root_path))\n # runner.registerInitialCondition('Use user provided occupancy schedule file at: ' + csv_file.to_s)\n else\n # Check if schedule file at several places\n # 1. Default fils path when run with OSW in CLI\n csv_path_lookup_1 = File.expand_path(\"../..\", measure_root_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"First lookup location: \" + csv_path_lookup_1\n runner.registerInfo(\"First lookup location: \" + csv_path_lookup_1)\n # 2. Default path when run with OpenStudio CLI\n csv_path_lookup_2 = File.expand_path(\"../..\", model_temp_run_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Second lookup location: \" + csv_path_lookup_2\n runner.registerInfo(\"Second lookup location: \" + csv_path_lookup_2)\n # 3. Default path when run with OpenStudio GUI\n csv_path_lookup_3 = File.expand_path(\"../../..\", model_temp_run_path) + \"/resources/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Third lookup location: \" + csv_path_lookup_3\n runner.registerInfo(\"Third lookup location: \" + csv_path_lookup_3)\n # 4. Generated files folder when run with rspec\n csv_path_lookup_4 = File.expand_path(\"..\", model_temp_run_path) + \"/generated_files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Forth lookup location: \" + csv_path_lookup_4\n runner.registerInfo(\"Forth lookup location: \" + csv_path_lookup_4)\n # 5. Generated files folder with OpenStudio V2.9.0+\n csv_path_lookup_5 = File.join(File.expand_path(\"../..\", model_temp_run_path), 'generated_files', @@default_occupant_schedule_filename)\n puts '#' * 80\n puts \"Fifth lookup location: \" + csv_path_lookup_5\n runner.registerInfo(\"Fifth lookup location: \" + csv_path_lookup_5)\n\n if File.file?(csv_path_lookup_1)\n csv_file = csv_path_lookup_1\n elsif File.file?(csv_path_lookup_2)\n csv_file = csv_path_lookup_2\n elsif File.file?(csv_path_lookup_3)\n csv_file = csv_path_lookup_3\n elsif File.file?(csv_path_lookup_4)\n csv_file = csv_path_lookup_4 \n elsif File.file?(csv_path_lookup_5)\n csv_file = csv_path_lookup_5\n else\n csv_file = ''\n end\n puts 'Use default occupancy schedule file at: ' + csv_file.to_s\n runner.registerInfo('Use default occupancy schedule file at: ' + csv_file.to_s)\n end\n\n # Get the spaces with occupancy count schedule available\n v_spaces_occ_sch = File.readlines(csv_file)[3].split(',') # Room ID is saved in 4th row of the occ_sch file\n v_headers = Array.new\n v_spaces_occ_sch.each do |space_occ_sch|\n if !['Room ID', 'Outdoor', 'Outside building'].include? space_occ_sch and !space_occ_sch.strip.empty?\n v_headers << space_occ_sch\n end\n end\n v_headers = [\"Time\"] + v_headers\n\n # report initial condition of model\n runner.registerInfo(\"The building has #{v_headers.length - 1} spaces with available occupant schedule file.\")\n\n # Read the occupant count schedule file and clean it\n clean_csv = File.readlines(csv_file).drop(6).join\n csv_table_sch = CSV.parse(clean_csv, headers: true)\n new_csv_table = csv_table_sch.by_col!.delete_if do |column_name, column_values|\n !v_headers.include? column_name\n end\n\n runner.registerInfo(\"Successfully read occupant count schedule from CSV file.\")\n runner.registerInfo(\"Creating new lighting schedules...\")\n\n # Create lighting schedule based on the occupant count schedule\n v_cols = Array.new\n v_ts = new_csv_table.by_col!['Time']\n v_headers.each do |header|\n if header != 'Time'\n space_name = header\n v_occ_n = new_csv_table.by_col![space_name]\n v_light = create_lighting_sch_from_occupancy_count(space_name, v_ts, v_occ_n, @@off_delay)\n v_cols << v_light\n end\n end\n\n runner.registerInfo(\"Writing new lighting schedules to CSV file.\")\n # Write new lighting schedule file to CSV\n file_name_light_sch = \"#{model_temp_run_path}/#{@@lighting_schedule_CSV_name}\"\n vcols_to_csv(v_cols, file_name_light_sch)\n\n # Add new lighting schedule from the CSV file created\n runner.registerInfo(\"Removing old OS:Lights and OS:Lights:Definition for office and conference rooms.\")\n # Remove old lights definition objects for office and conference rooms\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights definition object: ' + lght.lightsDefinition.name.to_s\n lght.lightsDefinition.remove\n end\n end\n end\n end\n\n # Remove old lights objects for office and conference rooms\n # Caution: the order of deletion matters\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights object: ' + lght.name.to_s\n lght.remove\n end\n end\n end\n end\n\n puts '---> Create new lighting schedules from CSV.'\n\n runner.registerInfo(\"Adding new OS:Schedule:File objects to the model....\")\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n v_headers.each_with_index do |s_space_name, i|\n if s_space_name == space.name.to_s\n col = i\n temp_file_path = file_name_light_sch\n sch_file_name = space.name.to_s + ' lght sch'\n schedule_file = get_os_schedule_from_csv(model, temp_file_path, sch_file_name, col, skip_row = 1)\n schedule_file.setMinutesperItem(@@minute_per_item.to_s)\n model = add_light(model, space, schedule_file)\n end\n end\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Finished creating and adding new lighting schedules for #{v_headers.length - 1} spaces.\")\n\n return true\n end",
"def span\n measure\n @span\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # System Type 2: PTHP, Residential\n # This measure creates:\n # a constant volume packaged terminal heat pump unit with DX heating \n # and cooling for each zone in the building\n \n always_on = model.alwaysOnDiscreteSchedule\n\n # Make a PTHP for each zone\n model.getThermalZones.each do |zone|\n \n fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)\n fan.setPressureRise(300)\n\n supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model,always_on)\n\n clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_cap_f_of_temp.setCoefficient1Constant(0.942587793)\n clg_cap_f_of_temp.setCoefficient2x(0.009543347)\n clg_cap_f_of_temp.setCoefficient3xPOW2(0.0018423)\n clg_cap_f_of_temp.setCoefficient4y(-0.011042676)\n clg_cap_f_of_temp.setCoefficient5yPOW2(0.000005249)\n clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.000009720)\n clg_cap_f_of_temp.setMinimumValueofx(17.0)\n clg_cap_f_of_temp.setMaximumValueofx(22.0)\n clg_cap_f_of_temp.setMinimumValueofy(13.0)\n clg_cap_f_of_temp.setMaximumValueofy(46.0)\n\n clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_cap_f_of_flow.setCoefficient1Constant(0.718954)\n clg_cap_f_of_flow.setCoefficient2x(0.435436)\n clg_cap_f_of_flow.setCoefficient3xPOW2(-0.154193)\n clg_cap_f_of_flow.setMinimumValueofx(0.75)\n clg_cap_f_of_flow.setMaximumValueofx(1.25)\n\n clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.342414409)\n clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.034885008)\n clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.000623700)\n clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.004977216)\n clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.000437951)\n clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.000728028)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofx(17.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofx(22.0)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofy(13.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.0)\n\n clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.1552)\n clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.1808)\n clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0256)\n clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.5)\n clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.5)\n\n clg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n clg_part_load_fraction.setCoefficient1Constant(0.75)\n clg_part_load_fraction.setCoefficient2x(0.25)\n clg_part_load_fraction.setCoefficient3xPOW2(0.0)\n clg_part_load_fraction.setMinimumValueofx(0.0)\n clg_part_load_fraction.setMaximumValueofx(1.0)\n\n clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,\n always_on,\n clg_cap_f_of_temp,\n clg_cap_f_of_flow,\n clg_energy_input_ratio_f_of_temp,\n clg_energy_input_ratio_f_of_flow,\n clg_part_load_fraction)\n\n htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_temp.setCoefficient1Constant(0.758746)\n htg_cap_f_of_temp.setCoefficient2x(0.027626)\n htg_cap_f_of_temp.setCoefficient3xPOW2(0.000148716)\n htg_cap_f_of_temp.setCoefficient4xPOW3(0.0000034992)\n htg_cap_f_of_temp.setMinimumValueofx(-20.0)\n htg_cap_f_of_temp.setMaximumValueofx(20.0)\n\n htg_cap_f_of_flow = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_flow.setCoefficient1Constant(0.84)\n htg_cap_f_of_flow.setCoefficient2x(0.16)\n htg_cap_f_of_flow.setCoefficient3xPOW2(0.0)\n htg_cap_f_of_flow.setCoefficient4xPOW3(0.0)\n htg_cap_f_of_flow.setMinimumValueofx(0.5)\n htg_cap_f_of_flow.setMaximumValueofx(1.5)\n\n htg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_energy_input_ratio_f_of_temp.setCoefficient1Constant(1.19248)\n htg_energy_input_ratio_f_of_temp.setCoefficient2x(-0.0300438)\n htg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(0.00103745)\n htg_energy_input_ratio_f_of_temp.setCoefficient4xPOW3(-0.000023328)\n htg_energy_input_ratio_f_of_temp.setMinimumValueofx(-20.0)\n htg_energy_input_ratio_f_of_temp.setMaximumValueofx(20.0)\n\n htg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n htg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.3824)\n htg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.4336)\n htg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0512)\n htg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.0)\n htg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.0)\n\n htg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n htg_part_load_fraction.setCoefficient1Constant(0.75)\n htg_part_load_fraction.setCoefficient2x(0.25)\n htg_part_load_fraction.setCoefficient3xPOW2(0.0)\n htg_part_load_fraction.setMinimumValueofx(0.0)\n htg_part_load_fraction.setMaximumValueofx(1.0)\n\n htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new( model,\n always_on,\n htg_cap_f_of_temp,\n htg_cap_f_of_flow,\n htg_energy_input_ratio_f_of_temp,\n htg_energy_input_ratio_f_of_flow,\n htg_part_load_fraction ) \n\n pthp = OpenStudio::Model::ZoneHVACPackagedTerminalHeatPump.new(model,\n always_on, \n fan,\n htg_coil,\n clg_coil,\n supplemental_htg_coil)\n\n pthp.setName(\"#{zone.name} PTHP\")\n pthp.addToThermalZone(zone)\n\n end\n\n \n return true\n \n end"
] |
[
"0.79848564",
"0.7639647",
"0.76355976",
"0.7170129",
"0.66926914",
"0.66926914",
"0.66718984",
"0.66311747",
"0.6599127",
"0.65870225",
"0.65324444",
"0.6481582",
"0.6405596",
"0.64028287",
"0.6333309",
"0.6283632",
"0.6283632",
"0.6283632",
"0.6281165",
"0.6269874",
"0.62425435",
"0.62203735",
"0.6198304",
"0.6196627",
"0.6196627",
"0.61319697",
"0.6107745",
"0.60714525",
"0.60513526",
"0.601827",
"0.6008391",
"0.6008391",
"0.60008335",
"0.5976995",
"0.59641606",
"0.5962238",
"0.5958165",
"0.59570605",
"0.59570605",
"0.59439784",
"0.5934565",
"0.5928137",
"0.5920926",
"0.5916211",
"0.59129107",
"0.5911706",
"0.59022516",
"0.5872101",
"0.5865909",
"0.58645797",
"0.5847354",
"0.583844",
"0.58373237",
"0.57887447",
"0.5772885",
"0.57687855",
"0.5756301",
"0.5745138",
"0.5740855",
"0.5723286",
"0.57180965",
"0.5713821",
"0.5698708",
"0.5697907",
"0.56978434",
"0.56891346",
"0.5688938",
"0.5685465",
"0.56740844",
"0.5662743",
"0.5649326",
"0.56483626",
"0.5646554",
"0.56390476",
"0.56390476",
"0.5633756",
"0.56218606",
"0.56218606",
"0.5608723",
"0.5608213",
"0.55982304",
"0.55982304",
"0.55982304",
"0.55982304",
"0.55982304",
"0.55982304",
"0.55982304",
"0.55982304",
"0.55982304",
"0.559522",
"0.559522",
"0.559522",
"0.55878526",
"0.558349",
"0.55677843",
"0.5567233",
"0.5564496",
"0.55636495",
"0.55590993",
"0.5556679",
"0.5547891"
] |
0.0
|
-1
|
checks if the identity is ready to be further processed e.g. all preconditions are fullfilled to start the oauth dance
|
def processable?
return true if self.user && !self.user.new_record?
# clean error on accept_terms
self.errors.delete(:accept_terms)
# check if terms of use have been accepted
self.errors.add(:accept_terms, :accepted) if self.accept_terms.to_i.zero?
self.errors.blank?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ready?\n config and\n config.authorization_url and\n tokens and\n tokens.access_token and\n tokens.refresh_token\n end",
"def is_ready_to_start?\n self.is_owner? ? self.ack_get_started_owner : ack_get_started_user\n end",
"def ready?\n self.class.ready?(@cloud_id, credentials: @credentials)\n end",
"def ready\n @valid = true\n end",
"def ready?\n running?(status) && running?(phase)\n end",
"def _ready?\n true\n end",
"def validate_can_start\n if aasm_states_to_check\n cannot_start! if requests_have_notices?\n end\n end",
"def ready?\n true\n end",
"def valid?\n @hydra.queue(request('verify'))\n end",
"def ready?; peek_current_state && (peek_current_state != :PRE_OPERATIONAL) end",
"def ready?\n end",
"def ready?\n pending? and not dependencies_have_failed? and dependencies_are_ready? and concurrency_available?\n end",
"def validic_user_provisioned?\n return (!self.validic_id.nil? && !self.validic_access_token.nil?)\n end",
"def ready?\n\t\t\t\t\tfalse\n\t\t\t\tend",
"def wait_until_ready\n # this method may be left unimplemented if that is applicable\n end",
"def verified_request?; end",
"def ready?\n @connected && @logged_in\n end",
"def ready?\n !has_expired?\n end",
"def ready?; @ready; end",
"def ready?; @ready; end",
"def ready?\n @ready == true\n end",
"def callback_phase\n error = request.params['error_reason'] || request.params['error']\n fail(OAuthError, error) if error\n @session_state = request.params['session_state']\n @id_token = request.params['id_token']\n @code = request.params['code']\n @claims, @header = validate_and_parse_id_token(@id_token)\n # validate_chash(@code, @claims, @header)\n super\n end",
"def initialized?\n server.present? && username.present? && api_token.present?\n end",
"def ready?\n @future.instance_eval do\n @continuation.ready?\n end\n end",
"def ensure_dependencies\n\t\tunless !self.date_of_booking.blank?\n\t\t\tself.errors[:date_of_booking] << \"=> Date of booking can't be empty\"\n\t\t\treturn false\n\t\tend\n\t\tunless ( self.company.resources.find_by_id(self.resource_id) )\n\t\t\tself.errors[:resource_not_present] << \"=> Requested resource is not available.\"\n\t\t\treturn false\n\t\tend\n\t\ttrue\n\tend",
"def allow_verification?\n logged_in? && correct_identifier? && pape_requirements_met?(auth_time)\n end",
"def ready?\n raise 'Not implemented!'\n end",
"def ready?\n true\n end",
"def ready?\n return _ready?\n rescue\n return false\n end",
"def ready?\n state == RUNNABLE_STATE\n end",
"def ready?\n # In test, we're always ready :-)\n return true if ENV['INSTANA_GEM_TEST']\n\n @state == :announced\n end",
"def ready?\n raise NotImplementedError\n end",
"def oauth_required\n invalid_oauth_response and return false unless current_token\n end",
"def ready?\n RestClient::Request.execute(:method => :get, :url => ready_path, :payload => {}, :timeout => TIMEOUT, :open_timeout => TIMEOUT) do |response, request, result|\n response.code == 200\n end \n rescue\n false\n end",
"def request_phase\n identifier ? start_oauth : get_identifier\n end",
"def ready?\n !@needs_reset && @start && @end\n end",
"def ready?\n @status == :ready\n end",
"def oauth_required\n head oauth.no_access! unless oauth.authenticated?\n end",
"def wait_until_ready\n # this method may be left unimplemented if that is applicable log\n end",
"def ready?\n @is_ready\n end",
"def ready\n return unless current_user.status==2\n @room = current_user.room\n publish_async(\"presence-room_#{@room.id}\",\"users_change\",{})\n current_user.update_attribute(:status, 3)\n if @room.show_next_question?\n if @next_question = choose_question!(@room)\n @room.users.each do |user|\n user.update_attribute(:status, 1)\n end\n question_id = @next_question.id\n else\n question_id = 0\n end\n\n #Publish next_question\n #If there're questions left, publish question_id\n #Else, publish question_id = 0, it will redirect user out of the room\n publish(\"presence-room_#{@room.id}\",\"next_question\", {\n question_id: question_id\n })\n render text: \"OK\",status: \"200\"\n end\n end",
"def ready?\n !!defined? @result\n end",
"def allow_verification?\n user_signed_in? && correct_identifier? && pape_requirements_met?(auth_time)\n end",
"def ready?\n status == DONE_STATE\n end",
"def finish_signed_up_but_email_not_confirmed?\n @identity.update(identity_params) && !@identity.confirmed?\n end",
"def ready_to_create?\n valid? && processed? && import_level_ok?\n end",
"def check\n @response = nil\n verified?\n end",
"def check(consumer, session, req)\n oid = consumer.begin(req.GET[@openid_param], @anonymous)\n req.env['rack.auth.openid.request'] = oid\n req.env['rack.errors'].puts(oid.message)\n p oid if $DEBUG\n\n ## Extension support\n extensions.each do |ext,args|\n oid.add_extension(ext::Request.new(*args))\n end\n\n session[:openid_param] = req.GET[openid_param]\n return_to_uri = return_to ? return_to : req.url\n session[:return_to] = return_to_uri\n immediate = session.key?(:setup_needed) ? false : immediate\n\n if oid.send_redirect?(realm, return_to_uri, immediate)\n uri = oid.redirect_url(realm, return_to_uri, immediate)\n redirect(uri)\n else\n confirm_post_params(oid, realm, return_to_uri, immediate)\n end\n rescue ::OpenID::DiscoveryFailure => e\n # thrown from inside OpenID::Consumer#begin by yadis stuff\n req.env['rack.errors'].puts([e.message, *e.backtrace]*\"\\n\")\n return foreign_server_failure\n end",
"def valid_to_proceed?\r\n decoded_auth_token.present? && decoded_auth_token[:user_id].present? && valid_token?\r\n end",
"def ensure_valid_checkid_request\n self.openid_request = checkid_request\n if !openid_request.is_a?(OpenID::Server::CheckIDRequest)\n redirect_to root_path, :alert => t(:identity_verification_request_invalid)\n elsif !allow_verification?\n flash[:notice] = logged_in? && !pape_requirements_met?(auth_time) ?\n t(:service_provider_requires_reauthentication_last_login_too_long_ago) :\n t(:login_to_verify_identity)\n session[:return_to] = proceed_path\n redirect_to login_path\n end\n end",
"def authentication_required!\n @access_token.nil?\n end",
"def do_complete\n # Ask the library to check the response that the server sent\n # us. Status is a code indicating the response type. info is\n # either nil or a string containing more information about\n # the return type.\n response = $consumer.complete(@req.query)\n \n css_class = \"error\"\n \n did_sreg = @req.query.fetch('did_sreg', nil)\n sreg_checked = did_sreg ? 'checked=\"checked\"' : ''\n \n if response.status == OpenID::FAILURE\n # In the case of failure, if info is non-nil, it is the\n # URL that we were verifying. We include it in the error\n # message to help the user figure out what happened.\n if response.identity_url\n message = \"Verification of #{response.identity_url} failed\"\n else\n message = 'Verification failed.'\n end\n\n # add on the failure message for a little debug info\n message += ' '+response.msg.to_s\n\n elsif response.status == OpenID::SUCCESS\n # Success means that the transaction completed without\n # error. If info is nil, it means that the user cancelled\n # the verification.\n css_class = \"alert\"\n\n message = \"You have successfully verified #{response.identity_url} as your identity.\"\n\n # get the signed extension sreg arguments\n sreg = response.extension_response('sreg')\n if sreg.length > 0\n message += \"<hr/> With simple registration fields:<br/>\"\n sreg.keys.sort.each {|k| message += \"<br/><b>#{k}</b>: #{sreg[k]}\"}\n elsif did_sreg\n message += \"<hr/> But the server does not support simple registration.\"\n end\n \n elsif response.status == OpenID::CANCEL\n message = \"Verification cancelled.\"\n\n else\n message = \"Unknown response status: #{response.status}\"\n\n end\n self.render(message, css_class, response.identity_url, sreg_checked)\n end",
"def ready; end",
"def ready; end",
"def ensure_autosignin_token!\n self.reset_autosignin_token! unless self.autosigninable_ready?\n end",
"def readyable?\n readyable\n end",
"def ready?\n # In test, we're always ready :-)\n return true if ENV.key?('INSTANA_TEST')\n\n # Occasionally Run Fork detection\n if rand(10) > 8\n if !@is_resque_worker && (@process[:pid] != Process.pid)\n ::Instana.logger.debug \"Instana: detected fork. (this pid: #{Process.pid}/#{Process.ppid}) Calling after_fork\"\n after_fork\n end\n end\n\n @state == :ready || @state == :announced\n rescue => e\n Instana.logger.debug { \"#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}\" }\n Instana.logger.debug { e.backtrace.join(\"\\r\\n\") } unless ENV.key?('INSTANA_TEST')\n return false\n end",
"def ready_to_ask\n whistle = @socket.read\n # TODO: what happens if we receive new identity data?\n case whistle\n when SecondWhistle\n true\n when SignedQuery\n self.signed_query = value\n false\n else\n unexpected_message query, SecondWhistle, SignedQuery\n end\n end",
"def ready?\n raise(\"Called #{self.class.name}.ready?\")\n end",
"def email_required?\n authorizations.length == 0 && !auth_temp_token\n end",
"def ready?\n running? && @event_received\n end",
"def handle_checkid_request\n if allow_verification?\n save_checkid_request\n redirect_to proceed_api_openid_provider_path(consumer_id)\n elsif openid_request.immediate\n render_response(openid_request.answer(false))\n else\n reset_session\n request = save_checkid_request\n session[:previous_url] = proceed_api_openid_provider_path(consumer_id)\n self.render_user_selection_page\n end\n end",
"def ready?\n status == \"RUNNING\"\n end",
"def initial_requirements_valid?()\n if all_required_documents_has_attachment?\n update_procedure_elements()\n\n email_data = {user: self.procedure.user, template: 'initial_validation_success', procedure_name: name}\n send_email(email_data)\n users = User.with_role :representante_facultad\n email_data = {owner: self.procedure.user, procedure_name: name , template: 'need_to_approve' }\n send_multiple_emails(users, email_data)\n\n return true\n else\n return false\n end\n end",
"def ready=(_); end",
"def ready?\n QA::Runtime::Logger.debug 'Checking Smocker readiness'\n get(\"#{admin_url}/version\")\n true\n # rescuing StandardError because RestClient::ExceptionWithResponse isn't propagating\n rescue StandardError => e\n QA::Runtime::Logger.debug \"Smocker not ready yet \\n #{e}\"\n false\n end",
"def ensure_autosignin_token\n self.reset_autosignin_token unless self.autosigninable_ready?\n end",
"def alive?\n !cst.nil? && !x_security_token.nil?\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def sex_offender_check_pending?\n !background_check_authorized_at.nil? && (!passed_sex_offender_check? && sex_offender_check_run_at.nil?)\n end",
"def check_in!\n ensure_can_check_in!\n self.update(status: :complete)\n end",
"def is_ready?\n return @ready\n end",
"def ensure_valid_checkid_request\n self.openid_request = checkid_request\n if !openid_request.is_a?(OpenID::Server::CheckIDRequest)\n redirect_to root_path, :alert => t('openid.identity_verification_request_invalid')\n elsif !allow_verification?\n flash[:notice] = user_signed_in? && !pape_requirements_met?(auth_time) ?\n t('openid.service_provider_requires_reauthentication_last_login_too_long_ago') :\n t('openid.login_to_verify_identity')\n session[:previous_url] = proceed_api_openid_provider_path\n redirect_to new_user_session_path(ltype:'sso')\n end\n end",
"def begin\n openid_url = params[:openid_url]\n\n if openid_url.blank?\n flash[:error] = \"To use this, please type in the box.\"\n redirect_to openid_root_path and return\n end\n\n # We begin using the consumer with the user's OpenID URL.\n #\n # This returns a CheckID Request object containing the discovered\n # information, with a method for building a redirect URL to the\n # server, as described later.\n #\n # The CheckID Request object may also be used to add extension\n # arguments to the request, using its add_extension_arg method.\n #\n # If no OpenID server is found, this raises a DiscoveryFailure.\n\n begin\n logger.info \"openid_url:#{openid_url} ...\"\n checkid_request = openid_consumer.begin openid_url\n logger.info \"openid_url:#{openid_url} success\"\n rescue OpenID::DiscoveryFailure\n logger.info \"openid_url:#{openid_url} failure\"\n flash[:error] = \"Couldn't find an OpenID for that URL\"\n redirect_to openid_root_path and return\n end\n\n # <tt>realm</tt> is the URL (or URL pattern) that identifies\n # your web site to the user when he or she is authorizing it.\n # The realm is typically the homepage URL of your site.\n #\n # In older versions of OpenID, the realm is called \"trust root\".\n\n realm = root_url # e.g. \"http://example.com\"\n\n # <tt>return_to</tt> is the URL that the OpenID server will send\n # the user back to after attempting to verify his or her identity.\n\n return_to = openid_complete_url # e.g. \"http://example.com/openid/complete\" \n\n # Next, you call the redirect_url method on the CheckIDRequest object.\n #\n # Returns a URL with an encoded OpenID request. The URL is the OpenID\n # provider's endpoint URL with parameters appended as query arguments.\n # You should redirect the user agent to this URL.\n #\n # OpenID 2.0 endpoints can also accept POST requests.\n\n url = checkid_request.redirect_url(realm, return_to)\n\n # We then redirect the user to the resulting URL where the user logs\n # in to their OpenID server, authorises your verification request and\n # is (normally) redirected to return URL you provided.\n #\n # When the user is redirected back to your application, the server\n # will append information about the response in the query string,\n # which the OpenID library will unpack.\n #\n # These next steps are done in the other program in this directory.\n\n redirect_to url and return\n\n end",
"def ready?\n self.state == :ready\n end",
"def complete?\n status == \"verified\"\n end",
"def ready?\n @latch.count == 0\n end",
"def wait_until_open_confirmed; end",
"def check_completion_status\n\t\trace = Race.find_by_id(self.race_id)\n\t\treturn if (race.nil?)\n\t\t\n\t\tself.is_complete = race.is_complete \n\t\tself.save\n\tend",
"def is_valid?\n !(consumer_key.nil? || consumer_secret.nil? || access_token.nil? || access_token_secret.nil?)\n end",
"def check_for_initial_install\n #Don't do anything if a user is logged in\n unless user_signed_in?\n #if the flag set in the seeds file still isn't set to true and there are no users, let's do our thing\n if ConcertoConfig[:setup_complete] == \"false\" && User.all.empty?\n redirect_to new_user_registration_path\n end\n end\n end",
"def core_endpoint_ready\n\t\t@endpoint_ready\n#\t\tUNIPROT_PROTEIN_LOOKUP_SHORT\n\tend",
"def first_time_authorized?\n self.authorized == true && self.message_sent == false\n end",
"def verify\n # nothing to do here, so just return\n end",
"def incomplete?\n running? || pending? || initialized?\n end",
"def done?\n waiting || verified || rejected\n end",
"def needs_request_identifier?\n false\n end",
"def alive?\n !client_security_token.nil? && !x_security_token.nil?\n end",
"def check_environment\n load_rscribd\n check_config\n check_fields\n end",
"def pre_check_in\n resp = if token.present?\n chip_client.pre_check_in(token:, demographic_confirmations:)\n else\n Faraday::Response.new(body: check_in.unauthorized_message.to_json, status: 401)\n end\n\n response.build(response: resp).handle\n end",
"def wait_for_ready\n sleep 0.1 until ready?\n end",
"def user_verification?; end",
"def ready_to_idle?\n logged_in? && !idling?\n end",
"def remote_server_ready?\n !@remote_server['locked'] &&\n @remote_server['built'] &&\n @remote_server['booted'] &&\n @remote_server['ip_addresses'].present? &&\n @remote_server['total_disk_size'].to_i > 1 &&\n pending_transactions.blank?\n end",
"def ready?\n # TODO: Not sure if this is the only state we should be matching.\n state == \"Detached\"\n end",
"def authentication_in_progress?\n request.path_info =~ /^\\/oauth/\n end",
"def authentication_in_progress?\n request.path_info =~ /^\\/oauth/\n end"
] |
[
"0.6451269",
"0.63725257",
"0.63293195",
"0.6221577",
"0.61388314",
"0.60509247",
"0.60039926",
"0.5998415",
"0.5983313",
"0.5946791",
"0.5944305",
"0.5934631",
"0.59164494",
"0.5915563",
"0.58971393",
"0.58752996",
"0.5862322",
"0.585778",
"0.5850673",
"0.5850673",
"0.58492255",
"0.58465177",
"0.5841793",
"0.5814586",
"0.5809046",
"0.58086556",
"0.58011216",
"0.57911944",
"0.5788521",
"0.5763776",
"0.57571906",
"0.5756795",
"0.57500625",
"0.57479745",
"0.5746488",
"0.5739043",
"0.57383114",
"0.5720263",
"0.57022995",
"0.56874454",
"0.56851137",
"0.56795096",
"0.5678504",
"0.567665",
"0.5670269",
"0.5664208",
"0.56584406",
"0.5656184",
"0.5647955",
"0.5638999",
"0.5628301",
"0.5627955",
"0.5623194",
"0.5623194",
"0.5608406",
"0.56075794",
"0.55946165",
"0.5594265",
"0.5593488",
"0.55843073",
"0.55836004",
"0.55724776",
"0.55575454",
"0.5553035",
"0.5547274",
"0.5535048",
"0.55290323",
"0.5519235",
"0.55175126",
"0.55175126",
"0.55175126",
"0.55175126",
"0.55175126",
"0.5515741",
"0.55067396",
"0.5505183",
"0.550394",
"0.55038226",
"0.54716",
"0.5464548",
"0.5459374",
"0.5457099",
"0.54564",
"0.5448545",
"0.5442081",
"0.5430268",
"0.54268414",
"0.542403",
"0.5418776",
"0.5400949",
"0.53957796",
"0.5394827",
"0.5393371",
"0.5390987",
"0.53866696",
"0.53782177",
"0.5377887",
"0.5370262",
"0.5369276",
"0.536875",
"0.536875"
] |
0.0
|
-1
|
Access the classes for the '' element. If a block is given, this invocation is being used to accumulate CSS class names; otherwise this invocation is being used to emit the CSS classes for inclusion in the '' element definition.
|
def page_classes
if block_given?
set_page_classes(*yield)
else
emit_page_classes
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da options\n end",
"def dom_class\n node['class']\n end",
"def class_name\n element.attribute_value \"class\"\n end",
"def classes(*args)\n [node ? node.classes(*args) : [], @wrapped_classes].flatten\n end",
"def append_class(block_name, appended_classes='')\n current_page_classes = current_page.data[block_name] || ''\n existing_classes_a = current_page_classes.split(' ')\n appended_classes_a = appended_classes.split(' ')\n classes = existing_classes_a.concat(appended_classes_a).reverse.join(' ')\n content_for(block_name, classes)\n end",
"def classes\n @class_list ||= Element::Classes.new(self)\n end",
"def dom_class\n\t\tnode['class']\n\tend",
"def css_classes(mod)\n if mod.respond_to?(:css_classes)\n return mod.css_classess\n else\n mod.class.name.underscore\n end\n end",
"def classes()\n return @driver.get_sc_core_query_element_classes(@handle, @index)\n end",
"def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end",
"def css_class(hay, needle); end",
"def each_class(text)\n\tscan_ignore_comments(/(struct|class)\\s+(\\w+)[^\\{\\;]*?\\{/m, text) do |match|\n\n\t\toffset = match.pre_match.length\n\t\tblock_start = offset + match[0].length\n\n\t\tname = match[2]\n\t\tend_offset = find_block_end(text, offset)\n\t\tbody = text[block_start, end_offset - block_start]\n\n\t\tyield name, body\n\tend\nend",
"def css_classes_for(*args)\n return nil if args.empty?\n\n conditions = args.extract_options!\n classes = args.dup\n conditions.each { |clas, condition| classes << clas if condition }\n classes.join(\" \")\n end",
"def css_classes_for(classname)\n css_classes_for_map classname, mapping\n end",
"def css_class_builtin(hay, needle); end",
"def add_class(class_name)\n @fragment.each_element do |c|\n c.attributes['class'] = ((c.attributes['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def css_class *a; CssString.new a.flatten.unshift(self).join '.' end",
"def add_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n if str.empty?\n str = c.to_s\n else\n str = str+\" #{c}\"\n end\n \n q.set_attribute(\"class\",str)\n end\n end",
"def add_class(class_name)\n @fragment.children.each do |c|\n c['class'] = ((c['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def have_css_classes(names) # rubocop:disable Style/PredicateName\n CustomMatchers::NodeCssClassMatcher.new names\nend",
"def css_class_standard(hay, needle); end",
"def css_classes\n css_classes = []\n css_classes << 'not-read' unless read\n css_classes << 'important' if important\n css_classes.join(' ')\n end",
"def get_classes\n (attr['class'] || '').downcase.split(' ').sort\n end",
"def evaluate_node_classes\n if @node.classes.is_a? Hash\n classes_with_params, classes_without_params = @node.classes.partition {|name,params| params and !params.empty?}\n\n # The results from Hash#partition are arrays of pairs rather than hashes,\n # so we have to convert to the forms evaluate_classes expects (Hash, and\n # Array of class names)\n classes_with_params = Hash[classes_with_params]\n classes_without_params.map!(&:first)\n else\n classes_with_params = {}\n classes_without_params = @node.classes\n end\n\n evaluate_classes(classes_with_params, @node_scope || topscope)\n evaluate_classes(classes_without_params, @node_scope || topscope)\n end",
"def classes\n kwattr_values(\"class\")\n end",
"def classes\n [\n @classes,\n helpers.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def classes\n [\n @classes,\n helpers.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def dom_class\n form_node['class']\n end",
"def css_class_names\n @css_class_names ||= []\n end",
"def classes\n [\n @classes,\n @view_context.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def process_class exp\n exp.shift unless auto_shift_type # node type\n in_klass exp.shift do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def classes\n return [] unless classes = self[\"class\"]\n classes.strip.split(/\\s+/)\n end",
"def get_existing_css_classes(link)\n link[\"class\"].to_s\n end",
"def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end",
"def css_class name\n attr \".#{name}\"\n end",
"def on_class(class_node); end",
"def classes\n return @classes if @classes\n @classes = @context.classes.sort.find_all{|c| c.document_self}.collect{|c| R2Doc.all_references[c.full_name]}\n end",
"def css_classes_for_map(classname, mapping)\n css = mapping[classname]\n css.class == String ? css_classes_for_map(css, mapping) : (css || [])\n end",
"def add_css_class(node, *new_class_names)\n class_names = (node['class'] || '').split(' ')\n return if new_class_names.all? { |klass| class_names.include?(klass) }\n class_names.concat(new_class_names)\n node['class'] = class_names.uniq.join(' ')\n end",
"def class_name=(name)\n %x{\n for (var i = 0, length = self.length; i < length; i++) {\n self[i].className = name;\n }\n }\n self\n end",
"def css_class\n result = [self.project.try(:css_class), self.try(:format).try(:css_class)].join(' ')\n result = 'other' unless CSS_CLASSES.include?(result)\n result += ' invisible' unless self.is_visible\n result\n end",
"def class_instance_blocks\n @class_instance_blocks ||= []\n end",
"def comp_class\n @xml += '<class> '\n while @i < @tokens.length\n case @tokens[@i].val\n when 'static', 'field'\n comp_class_var_dec\n next\n when 'constructor', 'function', 'method'\n comp_subroutine\n next\n else\n comp_line\n end\n end\n @xml += '</class> '\n @xml\n end",
"def classes\n 'has-star'\n end",
"def css_class\n end",
"def html_classes; end",
"def classes=(ary)\n `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`\n `this.__native__.className=result.join(' ')`\n return ary\n end",
"def each(&block)\n @class_map.each(&block);\n end",
"def classes(name = nil)\n find_children_of_type(\"Class\", name)\n end",
"def get_node_classes\n if ENV[\"classes\"]\n ENV[\"classes\"].split(\",\")\n else\n class_dir = File.expand_path(\"../../../modules/govuk/manifests/node\", __FILE__)\n all_class_name = Dir.glob(\"#{class_dir}/s_*.pp\").map { |filepath|\n File.basename(filepath, \".pp\")[2..-1] # Strip leading s_\n }\n all_class_name.reject {|c| $nodes_spec_blacklist_classes.include?(c) }\n end\n end",
"def class_names\n classes.map &:name\n end",
"def each_class_ns()\n @amqp.classes.each { |c| namespace(c.nsname) { yield c } }\n end",
"def get_container_class( current_piece )\n css_classes = current_piece.effects.join(' ') # current_piece.piece_selector + ' ' + current_piece.as_child_selector + ' ' +\n # how many columns are there?\n # handling data iteration?\n # Rails.logger.debug \"current_piece=#{current_piece.id},#{current_piece.title}, current_piece.is_container?=#{current_piece.is_container?}, current_piece.template.running_data_sources.present?=#{current_piece.template.running_data_sources.present?}\"\n if current_piece.is_container?\n running_data_item = current_piece.template.running_data_item\n if running_data_item.present?\n current_page = current_piece.template.page_generator.current_page_tag\n column_count = current_piece.template.running_data_source_sction_piece.column_count\n i = current_piece.template.running_data_item_index\n #Rails.logger.debug \"i=#{i}, column_count=#{column_count}, current_piece.template.running_data_source_sction_piece=#{current_piece.template.running_data_source_sction_piece.id}\"\n css_classes << ' data_first' if column_count>0 && i==0\n css_classes << ' data_last' if column_count>0 && ((i+1)%column_count==0)\n css_classes << \" data_#{i+1}\"\n\n case running_data_item.model\n when Spree::Taxon\n css_classes << ' data_current' if running_data_item.current?\n css_classes << ' data_current_ancestor' if current_page.ancestor_ids.include?(running_data_item.id)\n when Spree::Product\n when Spree::Post\n end\n\n end\n end\n if current_piece.parent.effects.present?\n css_classes << \" child_#{current_piece.nth_of_siblings}\"\n end\n\n css_classes\n end",
"def body_classes(classes=nil)\n if classes\n content_for(:body_classes) { classes }\n else\n body = yield_content(:body_classes)\n parts = []\n parts << body if body.present?\n parts << (signed_in? ? 'signed-in' : 'signed-out')\n parts << I18n.locale\n parts.join(' ')\n end\n end",
"def has_class?(name)\n a = []\n \n each do |e|\n if e.get(\"className\").split(\" \").index(name)\n a << e\n end\n end\n \n JS::Collection.new(a)\n end",
"def set_page_classes(*values)\n @page_classes = []\n @page_classes += values\n @page_classes += Array.wrap(yield) if block_given?\n @page_classes\n end",
"def body_classes\n THEMES.collect(&:css_class).uniq.join(' ')\n end",
"def classes\n @_classes ||= vedeu_classes - vedeu_exceptions - ignored_classes\n end",
"def classes\n\t\tlist = []\n\t\teach_class { |class_constant|\n\t\t\tlist\t<< class_constant\n\t\t}\n\t\treturn list\n\tend",
"def column container_class, content_class, &block\n concat content_tag(:div, :class => container_class) {\n content_tag(:div, :class => content_class) {\n capture(&block)\n }\n }\n end",
"def on_class(class_node)\n previous_category = nil\n previous_node_end_line = -1\n previous_method_name = nil\n walk_over_nested_class_definition(class_node) do |node, category|\n next unless node.respond_to?(:method_name)\n if previous_category && category != previous_category && node.loc.first_line - previous_node_end_line < 2\n add_offense(node, message: MSG)\n end\n\n if previous_method_name && previous_method_name == node.method_name && node.loc.first_line - previous_node_end_line > 1\n add_offense(node, message: \"Don't Use empty lines between same categories.\")\n end\n previous_category = category\n previous_node_end_line = node.loc.last_line\n previous_method_name = node.method_name\n end\n end",
"def class_name_node(node)\n node.descendants.detect do |e|\n e.is_a?(Parser::AST::Node) &&\n e.pair_type? &&\n e.children[0].children[0] == :class_name\n end\n end",
"def classes\n [self]\n end",
"def classes(name = nil)\n if name\n classes.find(:name => name)\n else\n @classes.flatten\n end\n end",
"def find_class(item)\n @driver.find_element(:class, item)\n end",
"def bootstrap_classes_for_collection coll, class_type='label'\n remaining = BOOTSTRAP_CLASSES.dup\n assignments = {}\n coll.each do |v|\n unless remaining.empty?\n assignments[v] = \"#{class_type}-#{remaining.shift}\"\n end\n end\n assignments\n end",
"def body_class(class_name=\"page\")\n content_for :body_class, class_name\n end",
"def remove_class name = nil\n each do |el|\n next unless el.respond_to? :get_attribute\n if name\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', (classes - [name]).uniq.join(\" \"))\n else\n el.remove_attribute(\"class\")\n end\n end\n self \n end",
"def process_classes(klass_hash, scope)\n interpolate_array(klass_hash['classes'], scope) +\n get_classes_from_groups(\n interpolate_array(klass_hash['class_groups'], scope), scope\n )\n end",
"def emit_page_classes\n @page_classes ||= default_page_classes\n @page_classes.flatten!\n @page_classes.compact_blank!\n @page_classes.map! { |c| c.to_s.gsub(/[^a-z_0-9-]/i, '_') }\n @page_classes.uniq!\n @page_classes.join(' ')\n end",
"def component_css_class\n ''\n end",
"def defclass\n rule(Stone::AST::Statement::Class).sep('class').identifier(reserved)\n .option(rule.sep('extends').identifier(reserved))\n .ast(class_body)\n end",
"def append_class(name); end",
"def append_class(name); end",
"def css_classes\n [\n \"version-#{status}\"\n ].join(' ')\n end",
"def css(klass='', opts={})\n if klass.is_a?(Hash)\n opts = klass\n klass = ''\n end\n mentos(:css, ['html', klass], opts)\n end",
"def singleton_class(&block)\n\t\tif block_given?\n\t\t(class << self; self; end).class_eval(&block)\n\t\tself\n\t\telse\n\t\t(class << self; self; end)\n\t\tend\n\tend",
"def css_classes(user=User.current)\n s = \"pull #{priority.try(:css_classes)}\"\n s << ' closed' if closed?\n s << ' created-by-me' if author_id == user.id\n s << ' assigned-to-me' if assigned_to_id == user.id\n s << ' assigned-to-my-group' if user.groups.any? {|g| g.id == assigned_to_id}\n end",
"def render_document_class(document = @document)\n document_classes = super(document) ? [super(document)] : []\n if homegrown_content?(document)\n document_classes << \"homegrown\"\n end\n return document_classes.join(' ')\n end",
"def render_document_class(document = @document)\n document_classes = super(document) ? [super(document)] : []\n if homegrown_content?(document)\n document_classes << \"homegrown\"\n end\n return document_classes.join(' ')\n end",
"def append_class!(options, scope, value)\n html = (options[scope] ||= {})\n\n if html[:class]\n html[:class] << \" #{value}\"\n else\n html[:class] = value\n end\n\n nil\n end",
"def append_page_classes(*values)\n @page_classes ||= default_page_classes\n @page_classes += values\n @page_classes += Array.wrap(yield) if block_given?\n @page_classes\n end",
"def classes\n @classes\n end",
"def block_class_params\n params.fetch(:block_class, {})\n end",
"def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end",
"def section_css_classes(umlaut_request, section_id, unused = nil)\n classes = [\"umlaut-section\", section_id]\n classes << 'umlaut-section-highlighted' if section_highlights(umlaut_request).should_highlight_section?(section_id)\n return classes\n end",
"def block_class() Block; end",
"def class_for_step(context, step)\n css_class = case\n # when context.workflow.current?(step)\n # 'nav-info'\n when context.workflow.completed?(step)\n 'nav-success'\n else 'nav-disabled'\n end\n\n css_class\n end",
"def class_decls; end",
"def each_inheritance(&block)\n @nodes.values.sort.each do |node|\n if node.super_class_node\n block.call node, node.super_class_node\n end\n end\n end",
"def render_plain_styleblock(name)\n @block_html.gsub('$modifier_class', '').gsub(' class=\"\"', '').prepend('<div class=\"styleguide-styleblock\">') << '</div>'\n end",
"def has_class?(c)\n find_all do |q|\n n=q.get_attribute(\"class\").split(\" \")\n n.index(c.to_s)\n end\n end",
"def classes(subnet)\n out = []\n subnet['classes'].each do |clas|\n out << %[ class \"#{clas['class']}\" {]\n out << raw_options(clas['raw_options'], 4)\n out << \" }\"\n out << ''\n end if subnet['classes']\n out << ''\n end",
"def inherit_type(klass, &block)\n Class.new(klass) do\n class_eval(&block) if block_given?\n end\n end",
"def classes\n self\n end",
"def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row #{self.kind}Row #{@tag}Row\" end",
"def in_class(name)\n name = class_name_from_sexp(name) if name.kind_of?(Sexp)\n @class_stack.unshift name\n yield\n @class_stack.shift\n end",
"def get_css_classes(output, post)\n # here we contruct the css classes to add to the media\n # we don't add zurb foundation flex-video tags for mp3 embeds\n css_classes = \"flex-video widescreen\" unless post.url[-4..-1] == \".mp3\"\n css_classes = css_classes + \" youtube\" if output.include? \"youtube.com\"\n css_classes = css_classes + \" vimeo\" if output.include? \"vimeo.com\"\n # Reset classes for images\n css_classes = \"image\" if post.url[-4..-1] == \".jpg\" or post.url[-4..-1] == \".gif\" or post.url[-4..-1] == \".png\" or post.url[-5..-1] == \".jpeg\"\n return css_classes\n end",
"def class_elements(*element_names)\n options = element_names.extract_options!\n\n patterned_elements \".%{element_name}\", *element_names, options.slice(:element_array)\n end",
"def classes\n @classes.values\n end"
] |
[
"0.64221454",
"0.6237864",
"0.61898285",
"0.61824834",
"0.6174134",
"0.6143465",
"0.6015646",
"0.58767366",
"0.58746195",
"0.5846111",
"0.5824157",
"0.5803588",
"0.58028924",
"0.579065",
"0.5775611",
"0.5730014",
"0.5634122",
"0.56323886",
"0.5612594",
"0.5611201",
"0.556757",
"0.55306333",
"0.5510977",
"0.5509533",
"0.5452361",
"0.54242116",
"0.54242116",
"0.54171294",
"0.5396614",
"0.5386716",
"0.53855664",
"0.5360547",
"0.53549355",
"0.5333831",
"0.53288907",
"0.5309763",
"0.52947325",
"0.5283475",
"0.52706563",
"0.52431846",
"0.5240848",
"0.52200216",
"0.5190157",
"0.5182511",
"0.5177498",
"0.51713485",
"0.51633114",
"0.5159776",
"0.5137457",
"0.5097879",
"0.5093444",
"0.5093277",
"0.50827205",
"0.5055871",
"0.50397",
"0.5037777",
"0.5025611",
"0.502405",
"0.5017802",
"0.50054693",
"0.4985491",
"0.4973685",
"0.49717012",
"0.49654582",
"0.49634555",
"0.4963216",
"0.4962477",
"0.49429125",
"0.49233016",
"0.49184322",
"0.4915151",
"0.4904219",
"0.49038383",
"0.49038383",
"0.49004564",
"0.48952663",
"0.4893699",
"0.48860747",
"0.48788378",
"0.48788378",
"0.48767924",
"0.48739314",
"0.4865064",
"0.4860624",
"0.48416662",
"0.48413515",
"0.48381513",
"0.48314852",
"0.48260123",
"0.4824427",
"0.48206198",
"0.481797",
"0.4806906",
"0.47867757",
"0.4785669",
"0.47848794",
"0.47836488",
"0.47825006",
"0.47796404",
"0.4773886"
] |
0.5748805
|
15
|
Set the classes for the '' element, eliminating any previous value.
|
def set_page_classes(*values)
@page_classes = []
@page_classes += values
@page_classes += Array.wrap(yield) if block_given?
@page_classes
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_classes(class_names)\n self.attr['class'] = ''\n class_names.each { |e| add_class(e) }\n end",
"def remove_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n str = str.split(\" \").find_all do |n|\n n != c.to_s\n end.join(\" \")\n \n q.set_attribute(\"class\",str)\n end\n end",
"def remove_class name = nil\n each do |el|\n next unless el.respond_to? :get_attribute\n if name\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', (classes - [name]).uniq.join(\" \"))\n else\n el.remove_attribute(\"class\")\n end\n end\n self \n end",
"def remove_class(*names)\n classes = class_names - names\n\n if classes.empty?\n `#@native.removeAttribute('class')`\n else\n `#@native.className = #{classes.join ' '}`\n end\n\n self\n end",
"def remove_class(a_class)\n self.attr['class'] = (attr['class'] || '').split(' ')\n .map { |e| e.gsub(/\\A#{ a_class.strip }\\z/, '') }\n .join(' ')\n end",
"def add_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n if str.empty?\n str = c.to_s\n else\n str = str+\" #{c}\"\n end\n \n q.set_attribute(\"class\",str)\n end\n end",
"def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end",
"def update_element_css_classes(obj, old_classes, new_classes)\n (old_classes - new_classes).each do |name|\n `#{obj.element}.classList.remove(#{name})`\n end\n\n (new_classes - old_classes).each do |name|\n `#{obj.element}.classList.add(#{name})`\n end\n end",
"def css_class value\n value.to_s.strip.downcase.gsub(' ','') # TODO update to strip out all non alphanumeric characters\n end",
"def classes=(ary)\n `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`\n `this.__native__.className=result.join(' ')`\n return ary\n end",
"def remove_class(names = nil)\n kwattr_remove(\"class\", names)\n end",
"def toggle_class(cls, value = nil)\n if value || (value.nil? && !has_class(cls))\n add_class cls\n else\n remove_class cls\n end\n end",
"def add_css_class(node, *new_class_names)\n class_names = (node['class'] || '').split(' ')\n return if new_class_names.all? { |klass| class_names.include?(klass) }\n class_names.concat(new_class_names)\n node['class'] = class_names.uniq.join(' ')\n end",
"def remove_class(*classes)\n classes.each { |cls| `#{@el}.classList.remove(#{cls})` }\n end",
"def set_class\n <<-CODE\n _lit = stack_pop();\n t1 = stack_pop();\n SET_CLASS(_lit, t1);\n stack_push(_lit);\n CODE\n end",
"def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da options\n end",
"def css_class *a; CssString.new a.flatten.unshift(self).join '.' end",
"def append_class_name(original_value, new_value)\n (original_value || \"\") << \" #{new_value}\"\n end",
"def class_name\n element.attribute_value \"class\"\n end",
"def join_dom_classes(*names)\n names.reject(&:blank?).join(' ')\n end",
"def classes\n @class_list ||= Element::Classes.new(self)\n end",
"def add_class(class_name)\n @fragment.each_element do |c|\n c.attributes['class'] = ((c.attributes['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def get_classes\n (attr['class'] || '').downcase.split(' ').sort\n end",
"def toggle_class(*names)\n to_remove, to_add = names.partition { |name| class_names.include? name }\n\n add_class(*to_add)\n remove_class(*to_remove)\n end",
"def append_class!(options, scope, value)\n html = (options[scope] ||= {})\n\n if html[:class]\n html[:class] << \" #{value}\"\n else\n html[:class] = value\n end\n\n nil\n end",
"def remove_class(sym)\n `var el=this.__native__,klass=sym.__value__`\n `el.className=el.className.replace(new(RegExp)('(^|\\\\\\\\s)'+klass+'(?:\\\\\\\\s|$)'),'$1')`\n return self\n end",
"def class_name=(name)\n %x{\n for (var i = 0, length = self.length; i < length; i++) {\n self[i].className = name;\n }\n }\n self\n end",
"def add_class(current_attributes, new_attributes)\n current_attributes ||= ''\n current_attributes.split(' ').push(new_attributes).join(' ')\n end",
"def add_css_class(name, attrs)\n classes = attrs[:class] || ''\n classes.strip!\n classes = ' ' + classes if !classes.blank?\n classes = name + classes\n attrs.merge(:class => classes)\n end",
"def add_class(*names)\n classes = class_names + names\n\n unless classes.empty?\n `#@native.className = #{classes.uniq.join ' '}`\n end\n\n self\n end",
"def css_class(hay, needle); end",
"def add_class(class_name)\n @fragment.children.each do |c|\n c['class'] = ((c['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def style_classes=(new_style_classes)\n @style_classes = new_style_classes\n if respond_to?(:setStyleClass)\n setStyleClass(new_style_classes.join(' '))\n end\n restyle!\n end",
"def remove_class class_name\n string=\"$('##{@id}').removeClass(#{class_name.to_s.inspect})\"\n @app.dom_on_sockets.execute string\n end",
"def html_classes; end",
"def unmodify_nilclass; end",
"def slideClasses\n blacklist = ['bigtext']\n @classes.reject { |klass| blacklist.include? klass }\n end",
"def ast_class=(value)\n if value.is_a? Class\n @ast_class = value\n return\n else\n value = value.to_s\n end\n # camel case the word and get class, similar logic to\n # ActiveSupport::Inflector.constantize but refactored to be specific\n # to the HTMLConverter class\n value.gsub!(/(?:^|_)([a-z])/) { Regexp.last_match[1].capitalize }\n @ast_class = Sablon::HTMLConverter.const_get(value)\n end",
"def append_class! klass\n return if already_marked? klass\n if has_class_attribute?\n add_class_to_attribute klass\n else\n add_class_and_attribute klass\n end\n end",
"def css_class_names\n @css_class_names ||= []\n end",
"def css_class_standard(hay, needle); end",
"def css_classes\n s = 'journal'\n s << ' has-notes' unless notes.blank?\n s << ' has-details' unless hr_change_details.blank?\n s\n end",
"def bp_class class_param\n class_param.blank? ? '' : class_param.strip().html_safe\n end",
"def append_class(name); end",
"def append_class(name); end",
"def css_classes\n css_classes = []\n css_classes << 'not-read' unless read\n css_classes << 'important' if important\n css_classes.join(' ')\n end",
"def dom_class\n node['class']\n end",
"def field_class\n css = (options[:class]||\"\").split(' ')\n css << 'exergue' if exergue\n css << 'warning' if warning\n css.join(' ')\n end",
"def emit_page_classes\n @page_classes ||= default_page_classes\n @page_classes.flatten!\n @page_classes.compact_blank!\n @page_classes.map! { |c| c.to_s.gsub(/[^a-z_0-9-]/i, '_') }\n @page_classes.uniq!\n @page_classes.join(' ')\n end",
"def add_classes(*classes)\n classes.map{|e| e.kind_of?(String) ? [e, nil] : e}.map{|p| add_class(*p)}\n end",
"def css_classes_for(*args)\n return nil if args.empty?\n\n conditions = args.extract_options!\n classes = args.dup\n conditions.each { |clas, condition| classes << clas if condition }\n classes.join(\" \")\n end",
"def alternate\n @class = @class != '' ? '' : ' class=\"alternate\"'\n end",
"def css_classes\n [\n \"version-#{status}\"\n ].join(' ')\n end",
"def classify_state(state)\n if state[1]\n state[0].each do |name|\n `#{@element}.classList.add(#{name})`\n end\n else\n state[0].each do |name|\n `#{@element}.classList.remove(#{name})`\n end\n end\n end",
"def html_options\n { :class => attribute }\n end",
"def css_class name\n attr \".#{name}\"\n end",
"def append_class_name! options, class_name\n key = options.has_key?('class') ? 'class' : :class \n unless options[key].to_s =~ /(^|\\s+)#{class_name}(\\s+|$)/\n options[key] = \"#{options[key]} #{class_name}\".strip\n end\n options\n end",
"def css_class\n result = [self.project.try(:css_class), self.try(:format).try(:css_class)].join(' ')\n result = 'other' unless CSS_CLASSES.include?(result)\n result += ' invisible' unless self.is_visible\n result\n end",
"def dom_class\n\t\tnode['class']\n\tend",
"def bootstrap_classes_for_collection coll, class_type='label'\n remaining = BOOTSTRAP_CLASSES.dup\n assignments = {}\n coll.each do |v|\n unless remaining.empty?\n assignments[v] = \"#{class_type}-#{remaining.shift}\"\n end\n end\n assignments\n end",
"def input_html_classes; end",
"def dom_class\n form_node['class']\n end",
"def class=(str)\n `this.__native__.className=str.__value__`\n return str\n end",
"def set_TransactionClass(value)\n set_input(\"TransactionClass\", value)\n end",
"def set_RailClass(value)\n set_input(\"RailClass\", value)\n end",
"def add_classes(rule_set, class_array)\n rule_set.each_selector do |selector|\n selector_name = selector.to_s.strip\n if selector_name[0] == '.'\n selector_name = selector_name[1, selector_name.length]\n unless class_array.include?(selector_name)\n class_array << selector_name\n end\n end\n end\n end",
"def remove_class(names = T.unsafe(nil)); end",
"def css_class\n @css_class ||= [\"project\", status.gsub(' ','-').downcase, (hideable? ? \"hideable\" : nil)].compact.join(\" \")\n end",
"def set_TransactionClass(value)\n set_input(\"TransactionClass\", value)\n end",
"def add_class(name); end",
"def add_class(name); end",
"def css_class_builtin(hay, needle); end",
"def css_class\n @css_class ||= \"project #{status.gsub(' ','-').downcase}\"\n end",
"def set_ResidentialClass(value)\n set_input(\"ResidentialClass\", value)\n end",
"def _wrapper_classes(attribute, *classes)\n classes.compact.tap do |klasses|\n klasses.push 'has-error' if self.errors_on?(attribute)\n end.join(' ')\n end",
"def strclass=(val) @records.set(GRT_STRCLASS, val); end",
"def marquer_blanche\n self.label = ''\n self.style_context.remove_class(\"case_noire\")\n self.style_context.remove_class(\"case_marquee\")\n end",
"def component_css_class\n ''\n end",
"def after_sclass(class_node); end",
"def html\n original_options = @html_options.dup\n self[:class] = \"#{self[:class]} #{alternate_class}\".strip if alternate\n html = super\n @html_options = original_options\n html\n end",
"def append_page_classes(*values)\n @page_classes ||= default_page_classes\n @page_classes += values\n @page_classes += Array.wrap(yield) if block_given?\n @page_classes\n end",
"def _class=(_class)\n validator = EnumAttributeValidator.new('String', [\"Other\", \"Absolute\", \"Possessory\", \"Qualified\", \"Good\"])\n unless validator.valid?(_class)\n fail ArgumentError, \"invalid value for '_class', must be one of #{validator.allowable_values}.\"\n end\n @_class = _class\n end",
"def removeUserAuthenticatorClass(classname)\n addauthenticatorclass_button.native.send_keys(:f5)\n find(:xpath, \".//td[input[@value='\" + classname + \"']]/img\").click\n end",
"def marquer_noire\n self.label = ''\n self.style_context.add_class(\"case_noire\")\n self.style_context.remove_class(\"case_marquee\")\n end",
"def toggle_class(sym)\n self.has_class?(sym) ? self.remove_class(sym) : self.add_class(sym);\n return self\n end",
"def add_class class_name\n string=\"$('##{@id}').addClass(#{class_name.to_s.inspect})\"\n @app.dom_on_sockets.execute string\n end",
"def add_class(sym)\n `if(!this.m$has_class_bool(sym)){var el=this.__native__,c=el.className,s=sym.__value__;el.className=(c.length>0)?c+' '+s:s;}`\n return self\n end",
"def set_CustomerClasses(value)\n set_input(\"CustomerClasses\", value)\n end",
"def ast_class=(value); end",
"def after_class(class_node); end",
"def trim_classes\n deletions = 1\n while deletions > 0 do\n deletions = 0\n @classes.each do |cls, value|\n next unless value.fetch(:sub_classes, {}).empty? && !value.has_key?(:examples)\n deletions += 1\n @classes.delete(cls)\n sc = value[:super_class]\n next unless sc\n puts \"trim class #{cls}, super-class #{sc}\"\n @classes[sc][:sub_classes].delete(cls) if @classes.fetch(sc, {})[:sub_classes]\n end\n end\n end",
"def classes\n kwattr_values(\"class\")\n end",
"def classes()\n return @driver.get_sc_core_query_element_classes(@handle, @index)\n end",
"def append_class(block_name, appended_classes='')\n current_page_classes = current_page.data[block_name] || ''\n existing_classes_a = current_page_classes.split(' ')\n appended_classes_a = appended_classes.split(' ')\n classes = existing_classes_a.concat(appended_classes_a).reverse.join(' ')\n content_for(block_name, classes)\n end",
"def alternate_class_again\n \"alternate\" if @class == \" class=\\\"alternate\\\"\"\n end",
"def xml=(klass); end",
"def reset\n\t\t\t\tself.clear\n\t\t\t\tme = self\n\t\t\t\t@default_values.each { |n, v| me[n] = v.is_a?(Class) ? nil : v }\n\t\t\tend",
"def comp_class\n @xml += '<class> '\n while @i < @tokens.length\n case @tokens[@i].val\n when 'static', 'field'\n comp_class_var_dec\n next\n when 'constructor', 'function', 'method'\n comp_subroutine\n next\n else\n comp_line\n end\n end\n @xml += '</class> '\n @xml\n end",
"def remove_classes(*args)\n args.each {|x| self.remove_class(x) }\n return self\n end",
"def toggle_class_name(class_name, condition)\n condition ? class_name : nil\n end"
] |
[
"0.7085044",
"0.6880239",
"0.6760475",
"0.66856855",
"0.66591895",
"0.6648968",
"0.65733975",
"0.62743205",
"0.6263523",
"0.6229792",
"0.62095803",
"0.6204296",
"0.5989905",
"0.5984917",
"0.59698254",
"0.596821",
"0.5905442",
"0.5840728",
"0.57988435",
"0.5798677",
"0.57885814",
"0.57700527",
"0.57523346",
"0.5731274",
"0.5725868",
"0.570152",
"0.5661328",
"0.5650653",
"0.56500137",
"0.5604522",
"0.55868423",
"0.5546054",
"0.5511698",
"0.5493891",
"0.54886484",
"0.5462279",
"0.5440386",
"0.5420433",
"0.54108703",
"0.54062974",
"0.53931904",
"0.53863376",
"0.5386185",
"0.5385957",
"0.5385957",
"0.5373577",
"0.5363918",
"0.53562516",
"0.53538513",
"0.53325474",
"0.5327466",
"0.5325655",
"0.5317116",
"0.52801377",
"0.5277895",
"0.52722216",
"0.5271372",
"0.5266179",
"0.52615833",
"0.5249966",
"0.52397645",
"0.52352434",
"0.52337337",
"0.5232964",
"0.5224281",
"0.52110946",
"0.5207389",
"0.5205427",
"0.52049994",
"0.519934",
"0.519934",
"0.5184991",
"0.51787657",
"0.51649135",
"0.515107",
"0.5131475",
"0.5105516",
"0.5100956",
"0.5098979",
"0.5097845",
"0.5096832",
"0.50804156",
"0.50788915",
"0.50716347",
"0.5044526",
"0.5035207",
"0.5034799",
"0.5007458",
"0.50067747",
"0.5005139",
"0.49948996",
"0.49945712",
"0.49807227",
"0.49678615",
"0.4965074",
"0.4961161",
"0.49576053",
"0.4953928",
"0.494672",
"0.494351"
] |
0.5630128
|
29
|
Add to the classes for the '' element.
|
def append_page_classes(*values)
@page_classes ||= default_page_classes
@page_classes += values
@page_classes += Array.wrap(yield) if block_given?
@page_classes
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end",
"def add_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n if str.empty?\n str = c.to_s\n else\n str = str+\" #{c}\"\n end\n \n q.set_attribute(\"class\",str)\n end\n end",
"def append_class(name); end",
"def append_class(name); end",
"def add_class(name); end",
"def add_class(name); end",
"def add_class(class_name)\n @fragment.each_element do |c|\n c.attributes['class'] = ((c.attributes['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def add_css_class(node, *new_class_names)\n class_names = (node['class'] || '').split(' ')\n return if new_class_names.all? { |klass| class_names.include?(klass) }\n class_names.concat(new_class_names)\n node['class'] = class_names.uniq.join(' ')\n end",
"def set_classes(class_names)\n self.attr['class'] = ''\n class_names.each { |e| add_class(e) }\n end",
"def add_css_class(name, attrs)\n classes = attrs[:class] || ''\n classes.strip!\n classes = ' ' + classes if !classes.blank?\n classes = name + classes\n attrs.merge(:class => classes)\n end",
"def add_class(class_name)\n @fragment.children.each do |c|\n c['class'] = ((c['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def add_class(*names)\n classes = class_names + names\n\n unless classes.empty?\n `#@native.className = #{classes.uniq.join ' '}`\n end\n\n self\n end",
"def css_class *a; CssString.new a.flatten.unshift(self).join '.' end",
"def add_class class_name\n string=\"$('##{@id}').addClass(#{class_name.to_s.inspect})\"\n @app.dom_on_sockets.execute string\n end",
"def update_element_css_classes(obj, old_classes, new_classes)\n (old_classes - new_classes).each do |name|\n `#{obj.element}.classList.remove(#{name})`\n end\n\n (new_classes - old_classes).each do |name|\n `#{obj.element}.classList.add(#{name})`\n end\n end",
"def add_class(current_attributes, new_attributes)\n current_attributes ||= ''\n current_attributes.split(' ').push(new_attributes).join(' ')\n end",
"def html_classes; end",
"def append_class!(options, scope, value)\n html = (options[scope] ||= {})\n\n if html[:class]\n html[:class] << \" #{value}\"\n else\n html[:class] = value\n end\n\n nil\n end",
"def add_classes(*classes)\n classes.map{|e| e.kind_of?(String) ? [e, nil] : e}.map{|p| add_class(*p)}\n end",
"def append_class(block_name, appended_classes='')\n current_page_classes = current_page.data[block_name] || ''\n existing_classes_a = current_page_classes.split(' ')\n appended_classes_a = appended_classes.split(' ')\n classes = existing_classes_a.concat(appended_classes_a).reverse.join(' ')\n content_for(block_name, classes)\n end",
"def classes\n @class_list ||= Element::Classes.new(self)\n end",
"def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da options\n end",
"def configure_adding_additional_css_classes\n if should_add_css_classes?\n @should_add_css_classes = true\n @css_classes_to_add = css_classes_to_add_from_config.to_s\n end\n end",
"def css_class(hay, needle); end",
"def join_dom_classes(*names)\n names.reject(&:blank?).join(' ')\n end",
"def append_class! klass\n return if already_marked? klass\n if has_class_attribute?\n add_class_to_attribute klass\n else\n add_class_and_attribute klass\n end\n end",
"def append_class_name! options, class_name\n key = options.has_key?('class') ? 'class' : :class \n unless options[key].to_s =~ /(^|\\s+)#{class_name}(\\s+|$)/\n options[key] = \"#{options[key]} #{class_name}\".strip\n end\n options\n end",
"def css_classes_for(*args)\n return nil if args.empty?\n\n conditions = args.extract_options!\n classes = args.dup\n conditions.each { |clas, condition| classes << clas if condition }\n classes.join(\" \")\n end",
"def append_class_name(original_value, new_value)\n (original_value || \"\") << \" #{new_value}\"\n end",
"def class_name=(name)\n %x{\n for (var i = 0, length = self.length; i < length; i++) {\n self[i].className = name;\n }\n }\n self\n end",
"def add_class(new_class)\n @classes << new_class\n end",
"def add_class(sym)\n `if(!this.m$has_class_bool(sym)){var el=this.__native__,c=el.className,s=sym.__value__;el.className=(c.length>0)?c+' '+s:s;}`\n return self\n end",
"def classes=(ary)\n `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`\n `this.__native__.className=result.join(' ')`\n return ary\n end",
"def add_class(name)\n @catalog.add_class(name) unless name == \"\"\n end",
"def css_class_standard(hay, needle); end",
"def remove_class name = nil\n each do |el|\n next unless el.respond_to? :get_attribute\n if name\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', (classes - [name]).uniq.join(\" \"))\n else\n el.remove_attribute(\"class\")\n end\n end\n self \n end",
"def on_class(class_node); end",
"def remove_class(*names)\n classes = class_names - names\n\n if classes.empty?\n `#@native.removeAttribute('class')`\n else\n `#@native.className = #{classes.join ' '}`\n end\n\n self\n end",
"def add_classes(rule_set, class_array)\n rule_set.each_selector do |selector|\n selector_name = selector.to_s.strip\n if selector_name[0] == '.'\n selector_name = selector_name[1, selector_name.length]\n unless class_array.include?(selector_name)\n class_array << selector_name\n end\n end\n end\n end",
"def class_name\n element.attribute_value \"class\"\n end",
"def css_class_builtin(hay, needle); end",
"def add_class file_path\n\n cleaned_html = AsdocTidy.clean_for_rexml(file_path)\n class_html\t = REXML::Document.new cleaned_html\n\n class_name = File.basename( file_path, \".html\" )\n log( \"Adding #{class_name}..\" )\n\n @class_names.push(class_name)\n add_as_element(class_html,METHOD,@method_names)\n add_as_element(class_html,PROTECTED_METHOD,@protected_method_names)\n add_as_element(class_html,CONSTANT,@constant_names)\n add_as_element(class_html,PROPERTY,@property_names)\n add_as_element(class_html,PROTECTED_PROPERTY,@protected_properties)\n\n gen_method_completions(class_html,METHOD)\n gen_method_completions(class_html,PROTECTED_METHOD)\n\n end",
"def component_css_class\n ''\n end",
"def render(item_container)\n # Add support for a dom_class attribute on the parent element\n item_container.dom_class = \"\"\n item_container.dom_class = options.delete(:dom_class) if options.has_key?(:dom_class)\n item_container.dom_id = options.delete(:dom_id) if options.has_key?(:dom_id)\n item_container.dom_class += \" \" + get_class(has_icons ? \"__with-icons\" : \"__without-icons\")\n item_container.dom_class += \" \" + get_class(has_toggles ? \"__with-toggles\" : \"__without-toggles\")\n item_container.dom_class += \" level-#{item_container.level}\"\n super\n end",
"def after_class(class_node); end",
"def emit_page_classes\n @page_classes ||= default_page_classes\n @page_classes.flatten!\n @page_classes.compact_blank!\n @page_classes.map! { |c| c.to_s.gsub(/[^a-z_0-9-]/i, '_') }\n @page_classes.uniq!\n @page_classes.join(' ')\n end",
"def css_class name\n attr \".#{name}\"\n end",
"def css_class\n end",
"def add_classes(*args)\n args.each {|x| self.add_class(x) }\n return self\n end",
"def input_html_classes; end",
"def css_classes\n s = 'journal'\n s << ' has-notes' unless notes.blank?\n s << ' has-details' unless hr_change_details.blank?\n s\n end",
"def remove_class(a_class)\n self.attr['class'] = (attr['class'] || '').split(' ')\n .map { |e| e.gsub(/\\A#{ a_class.strip }\\z/, '') }\n .join(' ')\n end",
"def set_class\n <<-CODE\n _lit = stack_pop();\n t1 = stack_pop();\n SET_CLASS(_lit, t1);\n stack_push(_lit);\n CODE\n end",
"def after_sclass(class_node); end",
"def css_class_names\n @css_class_names ||= []\n end",
"def add_css_classes_if_required(link)\n if @should_add_css_classes\n existing_classes = get_existing_css_classes(link)\n existing_classes = \" \" + existing_classes unless existing_classes.to_s.empty?\n link[\"class\"] = @css_classes_to_add + existing_classes\n end\n end",
"def remove_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n str = str.split(\" \").find_all do |n|\n n != c.to_s\n end.join(\" \")\n \n q.set_attribute(\"class\",str)\n end\n end",
"def toggle_class(*names)\n to_remove, to_add = names.partition { |name| class_names.include? name }\n\n add_class(*to_add)\n remove_class(*to_remove)\n end",
"def css_classes\n [\n \"version-#{status}\"\n ].join(' ')\n end",
"def style_classes=(new_style_classes)\n @style_classes = new_style_classes\n if respond_to?(:setStyleClass)\n setStyleClass(new_style_classes.join(' '))\n end\n restyle!\n end",
"def _wrapper_classes(attribute, *classes)\n classes.compact.tap do |klasses|\n klasses.push 'has-error' if self.errors_on?(attribute)\n end.join(' ')\n end",
"def css_class\n @css_class ||= [\"project\", status.gsub(' ','-').downcase, (hideable? ? \"hideable\" : nil)].compact.join(\" \")\n end",
"def css_classes_to_add_from_config\n config = @target_blank_config\n config.fetch(\"add_css_classes\")\n end",
"def set_page_classes(*values)\n @page_classes = []\n @page_classes += values\n @page_classes += Array.wrap(yield) if block_given?\n @page_classes\n end",
"def comp_class\n @xml += '<class> '\n while @i < @tokens.length\n case @tokens[@i].val\n when 'static', 'field'\n comp_class_var_dec\n next\n when 'constructor', 'function', 'method'\n comp_subroutine\n next\n else\n comp_line\n end\n end\n @xml += '</class> '\n @xml\n end",
"def css_classes\n css_classes = []\n css_classes << 'not-read' unless read\n css_classes << 'important' if important\n css_classes.join(' ')\n end",
"def css_class\n result = [self.project.try(:css_class), self.try(:format).try(:css_class)].join(' ')\n result = 'other' unless CSS_CLASSES.include?(result)\n result += ' invisible' unless self.is_visible\n result\n end",
"def bp_class class_param\n class_param.blank? ? '' : class_param.strip().html_safe\n end",
"def css_class\n @css_class ||= \"project #{status.gsub(' ','-').downcase}\"\n end",
"def dom_class\n node['class']\n end",
"def css_classes_for(classname)\n css_classes_for_map classname, mapping\n end",
"def add_class out, name, classes\n heading = if classes.all? { |klass| klass.module? } then\n name\n else\n superclass = classes.map do |klass|\n klass.superclass unless klass.module?\n end.compact.shift || 'Object'\n \"#{name} < #{superclass}\"\n end\n out << RDoc::Markup::Heading.new(1, heading)\n out << RDoc::Markup::BlankLine.new\n end",
"def add_class out, name, classes\n heading = if classes.all? { |klass| klass.module? } then\n name\n else\n superclass = classes.map do |klass|\n klass.superclass unless klass.module?\n end.compact.shift || 'Object'\n\n superclass = superclass.full_name unless String === superclass\n\n \"#{name} < #{superclass}\"\n end\n\n out << RDoc::Markup::Heading.new(1, heading)\n out << RDoc::Markup::BlankLine.new\n end",
"def render(item_container)\n # Add support for a dom_class attribute on the parent element\n item_container.dom_class = \"\"\n item_container.dom_class = options.delete(:dom_class) if options.has_key?(:dom_class)\n item_container.dom_id = options.delete(:dom_id) if options.has_key?(:dom_id)\n item_container.dom_class += has_icons ? \" simple-navigation__with-icons\" : \" simple-navigation__without-icons\"\n item_container.dom_class += has_toggles ? \" simple-navigation__with-toggles\" : \" simple-navigation__without-toggles\"\n super\n end",
"def field_class\n css = (options[:class]||\"\").split(' ')\n css << 'exergue' if exergue\n css << 'warning' if warning\n css.join(' ')\n end",
"def make_classy( line, file_identifier )\n\t\t# TODO: should add file name to end of class\n\t\tStayClassy::Builder::DEFAULT_CLASS_TAGS.each do |tag|\n\t\t\tif line.include?( \"<#{ tag }\" ) && !line.include?( \"class=\" )\n\t\t\t\tline = line.gsub( \"<#{ tag }\", \"<#{ tag } class=\\\"#{ @prefix }#{ tag }_#{ file_identifier }\\\"\" )\n\t\t\tend\n\t\tend\n\t\treturn line\n\tend",
"def addUserAuthenticatorClass(classname)\n addauthenticatorclass_button.click\n authenticatorclassesarray = all(:xpath, \".//input[contains(@id,'com.spigit.user.UserConfig.userAuthenticatorClasses')]\")\n authenticatorclassesarray[-1].set(classname)\n sleep(5)\n end",
"def remove_class(names = nil)\n kwattr_remove(\"class\", names)\n end",
"def add_class klass\n @display.print_class klass\n end",
"def build_item_class(i, options, active_ids)\n\n item_class = []\n\n item_class << options[:item_class]\n item_class << i.css_class\n\n if i.has_children?\n item_class << options[:item_with_children_class]\n else\n item_class << options[:item_without_children_class]\n end\n\n item_class << options[:active_class] if i.slug == params[:menu_id] || i.slug == request.original_fullpath.match(/(\\D+\\/{1}|\\D+)/)[0].gsub('/', '') || active_ids.include?(i.id)\n item_class.compact.join(\" \")\n end",
"def html_options\n { :class => attribute }\n end",
"def get_classes\n (attr['class'] || '').downcase.split(' ').sort\n end",
"def add_default_styling_selected(button_class)\n button_class ||= \"#3300FF\"\n button_class.insert(0, \"button \")\n end",
"def class_elements(*element_names)\n options = element_names.extract_options!\n\n patterned_elements \".%{element_name}\", *element_names, options.slice(:element_array)\n end",
"def remove_class(*classes)\n classes.each { |cls| `#{@el}.classList.remove(#{cls})` }\n end",
"def css_class(name_prefix='')\n\t\t\"#{name_prefix}list\"\n\tend",
"def bootstrap_classes_for_collection coll, class_type='label'\n remaining = BOOTSTRAP_CLASSES.dup\n assignments = {}\n coll.each do |v|\n unless remaining.empty?\n assignments[v] = \"#{class_type}-#{remaining.shift}\"\n end\n end\n assignments\n end",
"def classify_state(state)\n if state[1]\n state[0].each do |name|\n `#{@element}.classList.add(#{name})`\n end\n else\n state[0].each do |name|\n `#{@element}.classList.remove(#{name})`\n end\n end\n end",
"def update_class_list_variable(element)\n element.children.each do |child_elem|\n elem_name = child_elem.name.to_sym\n next unless self.class.constants.include?(elem_name)\n\n # Ex. Ekispert::DataVersion.new(child_elem)\n sub_instance = self.class.const_get(elem_name).new(child_elem)\n class_list_name = \"#{snakecase(elem_name)}_list\"\n # Ex. sub_instance.version_list << sub_instance\n self.send(class_list_name) << sub_instance\n end\n end",
"def extra_page_classes\n path_classes = page_classes.split(' ')\n\n blog_classes = []\n if current_page.data.tags\n blog_classes << current_page.data.tags.split(',').map{|t| \"tag-#{t.strip.gsub(/\\s+/, '-')}\"}\n end\n if current_page.data.category\n blog_classes << \"category-#{current_page.data.category.strip.gsub(/\\s+/, '-')}\"\n end\n classes = path_classes + blog_classes\n\n return classes.join(' ')\n end",
"def dom_class\n\t\tnode['class']\n\tend",
"def html_class(*args)\n (@html_class ||= HTMLClass.new) << args\n end",
"def add(classes)\n classes = classes.to_s.split(' ')\n classes.each { |cls| super cls }\n self\n end",
"def classes\n [\n @classes,\n helpers.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def classes\n [\n @classes,\n helpers.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def css_class\n @options[:class] || 'navigation'\n end",
"def add_authorizing_css_classes!(options, action, object)\r\n roles = object.role_authorizing(action).expand\r\n \r\n options[:class] ||= ''\r\n options[:class] = options[:class].split(/ /)\r\n options[:class] << 'visible-for' << roles.map(&:to_css_class).join(' ')\r\n options[:class] = options[:class].flatten.uniq.join(' ')\r\n end",
"def marquer_noire\n self.label = ''\n self.style_context.add_class(\"case_noire\")\n self.style_context.remove_class(\"case_marquee\")\n end",
"def dom_class\n form_node['class']\n end",
"def have_css_classes(names) # rubocop:disable Style/PredicateName\n CustomMatchers::NodeCssClassMatcher.new names\nend"
] |
[
"0.7722148",
"0.74526757",
"0.70900846",
"0.70900846",
"0.70598644",
"0.70598644",
"0.70283186",
"0.70261085",
"0.6987524",
"0.6928194",
"0.69225484",
"0.6858269",
"0.6824207",
"0.67648685",
"0.64623404",
"0.64436597",
"0.642449",
"0.6420374",
"0.6416678",
"0.63925755",
"0.63670206",
"0.63326114",
"0.63280624",
"0.63050354",
"0.6301062",
"0.62573767",
"0.61804414",
"0.6178931",
"0.61419386",
"0.6132609",
"0.6102221",
"0.60671186",
"0.60616523",
"0.6047977",
"0.6043871",
"0.60340625",
"0.60193086",
"0.6010281",
"0.5987156",
"0.5969861",
"0.5927264",
"0.5916657",
"0.5916625",
"0.5916132",
"0.590841",
"0.5900023",
"0.58969516",
"0.58907104",
"0.58860284",
"0.58854395",
"0.5841404",
"0.5835206",
"0.5814296",
"0.5813528",
"0.57929206",
"0.57922804",
"0.5789552",
"0.57835686",
"0.57782024",
"0.5727828",
"0.5686801",
"0.5682178",
"0.5678189",
"0.5677755",
"0.5676318",
"0.56723756",
"0.56562746",
"0.56472176",
"0.562101",
"0.56113535",
"0.560146",
"0.55896497",
"0.5588344",
"0.55658025",
"0.556053",
"0.55148625",
"0.5506199",
"0.5480922",
"0.5473356",
"0.54677844",
"0.54517263",
"0.544773",
"0.54420936",
"0.5440216",
"0.54273325",
"0.5425137",
"0.5421248",
"0.54074115",
"0.54063505",
"0.54034775",
"0.5401554",
"0.5400101",
"0.5368961",
"0.53662807",
"0.53662807",
"0.5365176",
"0.5362508",
"0.5352547",
"0.5333555",
"0.53300804"
] |
0.5861112
|
50
|
Emit the CSS classes for inclusion in the '' element definition.
|
def emit_page_classes
@page_classes ||= default_page_classes
@page_classes.flatten!
@page_classes.compact_blank!
@page_classes.map! { |c| c.to_s.gsub(/[^a-z_0-9-]/i, '_') }
@page_classes.uniq!
@page_classes.join(' ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da options\n end",
"def comp_class\n @xml += '<class> '\n while @i < @tokens.length\n case @tokens[@i].val\n when 'static', 'field'\n comp_class_var_dec\n next\n when 'constructor', 'function', 'method'\n comp_subroutine\n next\n else\n comp_line\n end\n end\n @xml += '</class> '\n @xml\n end",
"def html_classes; end",
"def classes\n @class_list ||= Element::Classes.new(self)\n end",
"def css_class\n end",
"def css_class *a; CssString.new a.flatten.unshift(self).join '.' end",
"def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end",
"def css_class(hay, needle); end",
"def add_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n if str.empty?\n str = c.to_s\n else\n str = str+\" #{c}\"\n end\n \n q.set_attribute(\"class\",str)\n end\n end",
"def css_classes_for(*args)\n return nil if args.empty?\n\n conditions = args.extract_options!\n classes = args.dup\n conditions.each { |clas, condition| classes << clas if condition }\n classes.join(\" \")\n end",
"def css_class name\n attr \".#{name}\"\n end",
"def css_classes\n css_classes = []\n css_classes << 'not-read' unless read\n css_classes << 'important' if important\n css_classes.join(' ')\n end",
"def classes\n [\n @classes,\n helpers.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def classes\n [\n @classes,\n helpers.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def css_classes_for(classname)\n css_classes_for_map classname, mapping\n end",
"def css_class\n result = [self.project.try(:css_class), self.try(:format).try(:css_class)].join(' ')\n result = 'other' unless CSS_CLASSES.include?(result)\n result += ' invisible' unless self.is_visible\n result\n end",
"def configure_adding_additional_css_classes\n if should_add_css_classes?\n @should_add_css_classes = true\n @css_classes_to_add = css_classes_to_add_from_config.to_s\n end\n end",
"def input_html_classes; end",
"def add_class(class_name)\n @fragment.each_element do |c|\n c.attributes['class'] = ((c.attributes['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def add_class(class_name)\n @fragment.children.each do |c|\n c['class'] = ((c['class']||'').split(' ') + [class_name]).join(' ')\n end\n end",
"def css_classes\n [\n \"version-#{status}\"\n ].join(' ')\n end",
"def classes\n [\n @classes,\n @view_context.render_document_class(@document),\n 'document',\n (\"document-position-#{@counter}\" if @counter)\n ].compact.flatten\n end",
"def css_class_names\n @css_class_names ||= []\n end",
"def css_class_builtin(hay, needle); end",
"def class_name\n element.attribute_value \"class\"\n end",
"def css_class_standard(hay, needle); end",
"def append_class(name); end",
"def append_class(name); end",
"def add_class out, name, classes\n heading = if classes.all? { |klass| klass.module? } then\n name\n else\n superclass = classes.map do |klass|\n klass.superclass unless klass.module?\n end.compact.shift || 'Object'\n \"#{name} < #{superclass}\"\n end\n out << RDoc::Markup::Heading.new(1, heading)\n out << RDoc::Markup::BlankLine.new\n end",
"def dom_class\n node['class']\n end",
"def field_class\n css = (options[:class]||\"\").split(' ')\n css << 'exergue' if exergue\n css << 'warning' if warning\n css.join(' ')\n end",
"def component_css_class\n ''\n end",
"def add_class out, name, classes\n heading = if classes.all? { |klass| klass.module? } then\n name\n else\n superclass = classes.map do |klass|\n klass.superclass unless klass.module?\n end.compact.shift || 'Object'\n\n superclass = superclass.full_name unless String === superclass\n\n \"#{name} < #{superclass}\"\n end\n\n out << RDoc::Markup::Heading.new(1, heading)\n out << RDoc::Markup::BlankLine.new\n end",
"def css_classes\n s = 'journal'\n s << ' has-notes' unless notes.blank?\n s << ' has-details' unless hr_change_details.blank?\n s\n end",
"def add_class file_path\n\n cleaned_html = AsdocTidy.clean_for_rexml(file_path)\n class_html\t = REXML::Document.new cleaned_html\n\n class_name = File.basename( file_path, \".html\" )\n log( \"Adding #{class_name}..\" )\n\n @class_names.push(class_name)\n add_as_element(class_html,METHOD,@method_names)\n add_as_element(class_html,PROTECTED_METHOD,@protected_method_names)\n add_as_element(class_html,CONSTANT,@constant_names)\n add_as_element(class_html,PROPERTY,@property_names)\n add_as_element(class_html,PROTECTED_PROPERTY,@protected_properties)\n\n gen_method_completions(class_html,METHOD)\n gen_method_completions(class_html,PROTECTED_METHOD)\n\n end",
"def add_class(name); end",
"def add_class(name); end",
"def tag_classes(tag)\n classes = [dom_id(tag)]\n \n classes << \"public\" if tag.public?\n \n if current_user.globally_excluded?(tag)\n classes << \"globally_excluded\"\n elsif current_user.subscribed?(tag)\n classes << \"subscribed\"\n elsif (current_user.id == tag.user_id) && tag.public\n classes << \"published\"\n end\n classes.join(\" \")\n end",
"def on_class(class_node); end",
"def add_css_class(name, attrs)\n classes = attrs[:class] || ''\n classes.strip!\n classes = ' ' + classes if !classes.blank?\n classes = name + classes\n attrs.merge(:class => classes)\n end",
"def view_options\n {\n class: css_classes\n }\n end",
"def html_options_for(namespace, css_classes); end",
"def have_css_classes(names) # rubocop:disable Style/PredicateName\n CustomMatchers::NodeCssClassMatcher.new names\nend",
"def html_options\n { :class => attribute }\n end",
"def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row #{self.kind}Row #{@tag}Row\" end",
"def css_class\n @css_class ||= [\"project\", status.gsub(' ','-').downcase, (hideable? ? \"hideable\" : nil)].compact.join(\" \")\n end",
"def append_class!(options, scope, value)\n html = (options[scope] ||= {})\n\n if html[:class]\n html[:class] << \" #{value}\"\n else\n html[:class] = value\n end\n\n nil\n end",
"def dom_class\n\t\tnode['class']\n\tend",
"def css_classes(mod)\n if mod.respond_to?(:css_classes)\n return mod.css_classess\n else\n mod.class.name.underscore\n end\n end",
"def add_class class_name\n string=\"$('##{@id}').addClass(#{class_name.to_s.inspect})\"\n @app.dom_on_sockets.execute string\n end",
"def display_class name\n return if name =~ /#|\\./\n klasses = []\n includes = []\n found = @stores.map do |store|\n begin\n klass = store.load_class name\n klasses << klass\n includes << [klass.includes, store] if klass.includes\n [store, klass]\n rescue Errno::ENOENT\n end\n end.compact\n return if found.empty?\n also_in = []\n includes.reject! do |modules,| modules.empty? end\n out = RDoc::Markup::Document.new\n add_class out, name, klasses\n add_includes out, includes\n found.each do |store, klass|\n comment = klass.comment\n class_methods = store.class_methods[klass.full_name]\n instance_methods = store.instance_methods[klass.full_name]\n attributes = store.attributes[klass.full_name]\n\n if comment.empty? and !(instance_methods or class_methods) then\n also_in << store\n next\n end\n add_from out, store\n unless comment.empty? then\n out << RDoc::Markup::Rule.new(1)\n out << comment\n end\n if class_methods or instance_methods or not klass.constants.empty? then\n out << RDoc::Markup::Rule.new(1)\n end\n unless klass.constants.empty? then\n out << RDoc::Markup::Heading.new(1, \"Constants:\")\n out << RDoc::Markup::BlankLine.new\n list = RDoc::Markup::List.new :NOTE\n constants = klass.constants.sort_by { |constant| constant.name }\n list.push(*constants.map do |constant|\n parts = constant.comment.parts if constant.comment\n parts << RDoc::Markup::Paragraph.new('[not documented]') if\n parts.empty?\n RDoc::Markup::ListItem.new(constant.name, *parts)\n end)\n out << list\n end\n add_method_list(out, \n (class_methods || []).map {|x| \".#{x}\"}, \n 'Class methods')\n add_method_list(out, \n (instance_methods || []).map {|x| \"#{x}\"}, \n 'Instance methods')\n add_method_list out, attributes, 'Attributes'\n out << RDoc::Markup::BlankLine.new\n end\n add_also_in out, also_in\n display out\n end",
"def add_css_class(node, *new_class_names)\n class_names = (node['class'] || '').split(' ')\n return if new_class_names.all? { |klass| class_names.include?(klass) }\n class_names.concat(new_class_names)\n node['class'] = class_names.uniq.join(' ')\n end",
"def render_class out, store, klass, also_in # :nodoc:\n comment = klass.comment\n # TODO the store's cache should always return an empty Array\n class_methods = store.class_methods[klass.full_name] || []\n instance_methods = store.instance_methods[klass.full_name] || []\n attributes = store.attributes[klass.full_name] || []\n\n if comment.empty? and\n instance_methods.empty? and class_methods.empty? then\n also_in << store\n return\n end\n\n add_from out, store\n\n class_document_comment out, comment\n\n if class_methods or instance_methods or not klass.constants.empty? then\n out << RDoc::Markup::Rule.new(1)\n end\n\n class_document_constants out, klass\n\n add_method_list out, class_methods, 'Class methods'\n add_method_list out, instance_methods, 'Instance methods'\n add_method_list out, attributes, 'Attributes'\n\n add_method_documentation out, klass if @show_all\n end",
"def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row\" end",
"def element_editor_classes(element)\n [\n 'element-editor',\n element.content_definitions.present? ? 'with-contents' : 'without-contents',\n element.nestable_elements.any? ? 'nestable' : 'not-nestable',\n element.taggable? ? 'taggable' : 'not-taggable',\n element.folded ? 'folded' : 'expanded',\n element.compact? ? 'compact' : nil,\n element.fixed? ? 'is-fixed' : 'not-fixed'\n ].join(' ')\n end",
"def css_classes_to_add_from_config\n config = @target_blank_config\n config.fetch(\"add_css_classes\")\n end",
"def class2html c\n name = c.name\n doc = REXML::Document.new\n html = doc.add_element \"html\", \"xmlns\" => \"http://www.w3.org/1999/xhtml\", \"xml:lang\" => \"en\", \"lang\" => \"en\"\n head = html.add_element \"head\"\n head.add_element \"meta\", \"http-equiv\" => \"Content-type\", \"content\" => \"text/html; charset=utf-8\"\n title = head.add_element \"title\"\n title.text = \"Class #{name}\"\n css = head.add_element \"link\", \"rel\" => \"stylesheet\", \"href\" => \"../mofhtml.css\", \"type\" => \"text/css\", \"media\" => \"screen,projection,print\"\n body = html.add_element \"body\"\n c.to_html body.add_element(\"div\", \"class\" => \"outer_div\")\n doc\nend",
"def generate_custom_classes\r\n\t\t# TODO: this method assumes an application to find the metadata on; the metadata should be part of this class instance instead, shared with the app when present\r\n\t\tparent_class_name = {\r\n\t\t\t'CustomMaterial' => 'MaterialBase',\r\n\t\t\t'Effect' => 'Effect',\r\n\t\t\t'Behavior' => 'Behavior',\r\n\t\t\t'RenderPlugin' => 'RenderPlugin'\r\n\t\t}\r\n\t\t@class_by_ref = {}\r\n\t\t@doc.xpath('/UIP/Project/Classes/*').each do |reference|\r\n\t\t\tpath = absolute_path( reference['sourcepath'] )\r\n\t\t\tnext unless File.exist?( path )\r\n\t\t\tparent_class = app.metadata.by_name[ parent_class_name[reference.name] ]\r\n\t\t\traise \"Error, unsupported custom class #{reference.name}\" unless parent_class\r\n\t\t\tparent_props = parent_class.properties\r\n\t\t\tnew_defaults = Hash[ reference.attributes.map{ |name,attr| [name,attr.value] }.select{ |name,val| parent_props[name] } ]\r\n\t\t\tproperty_el = case reference.name\r\n\t\t\t\twhen 'CustomMaterial', 'Effect', 'RenderPlugin'\r\n\t\t\t\t\tdoc = Nokogiri.XML(File.read(path,encoding:'utf-8'))\r\n\t\t\t\t\tdoc.at('/*/MetaData') || doc.at('/*/metadata') # Some render plugins in the wild use lower-case tag name :/\r\n\t\t\t\twhen 'Behavior'\r\n\t\t\t\t\tlua = File.read(path,encoding:'utf-8')\r\n\t\t\t\t\tmeta = lua[ /--\\[\\[(.+?)(?:--)?\\]\\]/m, 1 ]\r\n\t\t\t\t\tNokogiri.XML(\"<MetaData>#{meta}</MetaData>\").root\r\n\t\t\tend\r\n\t\t\t@class_by_ref[ \"##{reference['id']}\" ] = app.metadata.create_class( property_el, parent_class, reference.name, new_defaults )\r\n\t\tend\r\n\t\tnil\r\n\tend",
"def page_classes\n if block_given?\n set_page_classes(*yield)\n else\n emit_page_classes\n end\n end",
"def css_class(name_prefix='')\n\t\t\"#{name_prefix}list\"\n\tend",
"def render_document_class(document = @document)\n document_classes = super(document) ? [super(document)] : []\n if homegrown_content?(document)\n document_classes << \"homegrown\"\n end\n return document_classes.join(' ')\n end",
"def render_document_class(document = @document)\n document_classes = super(document) ? [super(document)] : []\n if homegrown_content?(document)\n document_classes << \"homegrown\"\n end\n return document_classes.join(' ')\n end",
"def classes()\n return @driver.get_sc_core_query_element_classes(@handle, @index)\n end",
"def definition\n \"class << #{full_name}\"\n end",
"def render(item_container)\n # Add support for a dom_class attribute on the parent element\n item_container.dom_class = \"\"\n item_container.dom_class = options.delete(:dom_class) if options.has_key?(:dom_class)\n item_container.dom_id = options.delete(:dom_id) if options.has_key?(:dom_id)\n item_container.dom_class += \" \" + get_class(has_icons ? \"__with-icons\" : \"__without-icons\")\n item_container.dom_class += \" \" + get_class(has_toggles ? \"__with-toggles\" : \"__without-toggles\")\n item_container.dom_class += \" level-#{item_container.level}\"\n super\n end",
"def css_classes_for_map(classname, mapping)\n css = mapping[classname]\n css.class == String ? css_classes_for_map(css, mapping) : (css || [])\n end",
"def record_class_definitions\n extant, novel = [], []\n ObjectSpace.each_object(Class) { |k| extant << k }\n yield\n ObjectSpace.each_object(Class) { |k| novel << k if !extant.include?(k) }\n novel\n end",
"def append_page_classes(*values)\n @page_classes ||= default_page_classes\n @page_classes += values\n @page_classes += Array.wrap(yield) if block_given?\n @page_classes\n end",
"def class_decls; end",
"def join_dom_classes(*names)\n names.reject(&:blank?).join(' ')\n end",
"def css_class\n @css_class ||= \"project #{status.gsub(' ','-').downcase}\"\n end",
"def classes(*args)\n [node ? node.classes(*args) : [], @wrapped_classes].flatten\n end",
"def compileclass(output,classname)\n #File.open(output, \"a\") { |f| f.write \"<class>\\n <\" }\n end",
"def classes\n kwattr_values(\"class\")\n end",
"def dom_class\n form_node['class']\n end",
"def css_class\n @options[:class] || 'navigation'\n end",
"def class_document_constants out, klass # :nodoc:\n return if klass.constants.empty?\n\n out << RDoc::Markup::Heading.new(1, \"Constants:\")\n out << RDoc::Markup::BlankLine.new\n list = RDoc::Markup::List.new :NOTE\n\n constants = klass.constants.sort_by { |constant| constant.name }\n\n list.items.concat constants.map { |constant|\n parts = constant.comment.parts if constant.comment\n parts << RDoc::Markup::Paragraph.new('[not documented]') if\n parts.empty?\n\n RDoc::Markup::ListItem.new(constant.name, *parts)\n }\n\n out << list\n out << RDoc::Markup::BlankLine.new\n end",
"def classes=(ary)\n `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`\n `this.__native__.className=result.join(' ')`\n return ary\n end",
"def css_class(name_prefix='')\n\t\t\"#{name_prefix}group\"\n\tend",
"def _wrapper_classes(attribute, *classes)\n classes.compact.tap do |klasses|\n klasses.push 'has-error' if self.errors_on?(attribute)\n end.join(' ')\n end",
"def add_authorizing_css_classes!(options, action, object)\r\n roles = object.role_authorizing(action).expand\r\n \r\n options[:class] ||= ''\r\n options[:class] = options[:class].split(/ /)\r\n options[:class] << 'visible-for' << roles.map(&:to_css_class).join(' ')\r\n options[:class] = options[:class].flatten.uniq.join(' ')\r\n end",
"def class_elements(*element_names)\n options = element_names.extract_options!\n\n patterned_elements \".%{element_name}\", *element_names, options.slice(:element_array)\n end",
"def css(klass='', opts={})\n if klass.is_a?(Hash)\n opts = klass\n klass = ''\n end\n mentos(:css, ['html', klass], opts)\n end",
"def set_page_classes(*values)\n @page_classes = []\n @page_classes += values\n @page_classes += Array.wrap(yield) if block_given?\n @page_classes\n end",
"def class_document name, found, klasses, includes, extends\n also_in = []\n\n out = RDoc::Markup::Document.new\n\n add_class out, name, klasses\n\n add_includes out, includes\n add_extends out, extends\n\n found.each do |store, klass|\n render_class out, store, klass, also_in\n end\n\n add_also_in out, also_in\n\n out\n end",
"def css_class(prefix='')\n\t\t\"#{prefix}contact\"\n\tend",
"def after_sclass(class_node); end",
"def classes; end",
"def add_classes(rule_set, class_array)\n rule_set.each_selector do |selector|\n selector_name = selector.to_s.strip\n if selector_name[0] == '.'\n selector_name = selector_name[1, selector_name.length]\n unless class_array.include?(selector_name)\n class_array << selector_name\n end\n end\n end\n end",
"def set_classes(class_names)\n self.attr['class'] = ''\n class_names.each { |e| add_class(e) }\n end",
"def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end",
"def add_authorizing_css_classes!(options, action, object)\n action = :\"#{action} #{object.class.name.underscore.downcase}\"\n roles = object.role_authorizing(action).expand(object)\n options[:class] ||= ''\n options[:class] = options[:class].split(/ /)\n options[:class] << 'visible_for' << roles.map { |role| role_to_css_class(role) }.join(' ')\n options[:class] = options[:class].flatten.uniq.join(' ')\n end",
"def classes\n return @classes if @classes\n @classes = @context.classes.sort.find_all{|c| c.document_self}.collect{|c| R2Doc.all_references[c.full_name]}\n end",
"def get_existing_css_classes(link)\n link[\"class\"].to_s\n end",
"def define_elements!\n element_names.each do |name, selector|\n metaclass.class_eval(<<-END, __FILE__, __LINE__)\n def #{name}(*filters, &block)\n make_element_set(#{name.inspect}, #{selector.inspect}, *filters, &block)\n end\n END\n end\n end",
"def generate_class_files\n debug_msg \"Generating class documentation in #@outputdir\"\n templatefile = Pathname.new(File.dirname(__FILE__) + '/template/railsfish/classpage.rhtml')\n \n @classes.each do |klass|\n debug_msg \" working on %s (%s)\" % [ klass.full_name, klass.path ]\n outfile = @outputdir + klass.path\n rel_prefix = @outputdir.relative_path_from( outfile.dirname )\n svninfo = self.get_svninfo( klass )\n \n debug_msg \" rendering #{outfile}\"\n self.render_template( templatefile, binding(), outfile )\n end\n end",
"def class_for_step(context, step)\n css_class = case\n # when context.workflow.current?(step)\n # 'nav-info'\n when context.workflow.completed?(step)\n 'nav-success'\n else 'nav-disabled'\n end\n\n css_class\n end",
"def classes\n\t\tlist = []\n\t\teach_class { |class_constant|\n\t\t\tlist\t<< class_constant\n\t\t}\n\t\treturn list\n\tend",
"def classes\n 'has-star'\n end",
"def after_class(class_node); end"
] |
[
"0.6809233",
"0.6532971",
"0.6450472",
"0.6357284",
"0.63551396",
"0.6306282",
"0.6257774",
"0.619884",
"0.6198387",
"0.6197295",
"0.61258864",
"0.61211944",
"0.611239",
"0.611239",
"0.60921395",
"0.6091575",
"0.6088885",
"0.60771734",
"0.6056501",
"0.6045831",
"0.60227454",
"0.60139936",
"0.6003484",
"0.5993868",
"0.59385353",
"0.5909752",
"0.58665824",
"0.58665824",
"0.5855925",
"0.5854062",
"0.58440363",
"0.58263427",
"0.5818107",
"0.5808279",
"0.5806671",
"0.5773576",
"0.5773576",
"0.5762504",
"0.5752368",
"0.57381034",
"0.57119197",
"0.5711064",
"0.56970674",
"0.56764424",
"0.5672152",
"0.56710654",
"0.5653487",
"0.5650758",
"0.5647603",
"0.56326085",
"0.5617919",
"0.5594004",
"0.55642134",
"0.5557132",
"0.5546192",
"0.5541501",
"0.55394405",
"0.5536625",
"0.5521334",
"0.5511618",
"0.5496103",
"0.5496103",
"0.54953676",
"0.5482046",
"0.5468778",
"0.54677236",
"0.54509497",
"0.5448084",
"0.544743",
"0.5443024",
"0.54393196",
"0.54011047",
"0.5395876",
"0.5395407",
"0.53882015",
"0.5367948",
"0.53585786",
"0.53408384",
"0.5340663",
"0.53383434",
"0.5337835",
"0.5331477",
"0.53212494",
"0.53083605",
"0.5308348",
"0.529139",
"0.52755606",
"0.52721083",
"0.526939",
"0.526094",
"0.5260626",
"0.5260438",
"0.52452093",
"0.52260506",
"0.52084833",
"0.51909745",
"0.518822",
"0.5186574",
"0.51808673",
"0.51780534"
] |
0.65412295
|
1
|
GET /euclid_users/1 GET /euclid_users/1.json
|
def show
@euclid_user = EuclidUser.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @euclid_user }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end",
"def new\n @euclid_user = EuclidUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @euclid_user }\n end\n end",
"def get_users(request); end",
"def getUser( user_id)\n params = Hash.new\n params['user_id'] = user_id\n return doCurl(\"get\",\"/user\",params)\n end",
"def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end",
"def get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end",
"def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end",
"def search_for_user(params) # :yields: JSON\n uri=URI.parse(@uri_builder.get_user_contents(Api_options::USER::SEARCH, params))\n http=HttpHandler.initiate_http(uri)\n begin\n response=HttpHandler.get_response(http,uri)\n rescue ArgumentError\n puts \"Request failed with code: #{response.code}\"\n else\n @response_status=true\n return response\n end\n end",
"def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end",
"def get_user_id(full_user_name)\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/users\"\n puts \"@url is #{@url}\"\n \n @payload={'search_term': full_user_name}\n puts(\"@payload is #{@payload}\")\n \n @getResponse = HTTParty.get(@url, :body => @payload.to_json, :headers => $header)\n puts(\" GET to get user has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n user_data = @getResponse.parsed_response\n user_id = nil\n\n user_data.each do |user_info|\n if user_info[\"name\"] == full_user_name\n user_id = user_info[\"id\"]\n end\n end\n\n return user_id\nend",
"def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end",
"def userReponses\n user=User.find(params[:userId])\n render :json=> user.response\n end",
"def index\n render json: current_org.users\n end",
"def users_for_a_project\n uri = \"#{@api_url}/#{@project_id}/users?access_token=#{@access_token}\"\n get uri\n end",
"def get_user_info(list)\n\trequire 'net/http'\n\tNet::HTTP.get(ENV[\"VERITAS-USER-SERVER\"] + \"/users?user_ids=#{list}\")\nend",
"def get_user_details\n @user = User.find_by_id(params[:user_id])\n render json: @user\n end",
"def user\n render :json=> User.find(params[:id])\n end",
"def get \n render :json => User.find(params[:id])\n end",
"def get_user_info\n get(\"/api/v1/oauth_user_info.json\")\n end",
"def list_users\n self.class.get('/users')\n end",
"def show\n @euclid_user_message = EuclidUserMessage.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @euclid_user_message }\n end\n end",
"def index\n json_response(User.all) \n end",
"def user_management_get_single_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users/{id}\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\n \"id\" => id,\n }\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.get query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif response.code == 404\n raise APIException.new \"Not Found\", 404, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end",
"def get_user_data(uid)\n @conn.get(\"/api/v1/users/#{uid}\")\n end",
"def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end",
"def get_user_info(user)\n if user.respond_to? :id\n username = Digest::MD5.hexdigest(user.id.to_s)\n else\n username = user\n end\n\n begin\n url = \"#{DOMAIN}/#{ORG}/#{APP}/users/#{username}\"\n response = RestClient.get(url, \"Authorization\" => \"Bearer #{access_token}\", content_type: :json, accept: :json)\n res = JSON.parse(response.body)\n p res[\"entities\"]\n rescue => e\n puts e.response\n end\n end",
"def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def show\n\tuser_completed = @user.as_json(:only => [:id, :username, :login, :email, :guild_id, :otp_secret, :otp_required_for_login])\n\t\t\t\t\t\t.merge(guild: @user.guild, achievments: @user.achievments)\n\tif self.user_owner?\n \trender json: user_completed, status: :ok\n\telse\n \trender json: user_completed.except(:email, :otp_required_for_login), status: :ok\n\tend\n end",
"def for_id(user_id)\n Iterable.request(conf, \"/users/byUserId/#{user_id}\").get\n end",
"def get_usr_info\n d = DistanceService.new\n d.get_usr_location(params[:usr_location])\n @user_info = $redis.hgetall('user')\n render json: @user_info\n # byebug\n # respond_to do |format|\n # format.js {render layout: false}\n # end\n\n end",
"def get_user_data(user_id, auth_token)\n request = Typhoeus::Request.new(\n \"https://oauth2-api.mapmyapi.com/v7.0/user/self/\",\n method: :get,\n body: {\n 'Content-Type' => \"application/json\",\n 'Api-Key' => ID,\n 'Authorization' => \"Bearer #{auth_token}\"\n },\n headers: {\n 'Api-Key' => ID,\n 'Authorization' => auth_token\n }\n )\n request.run\n response = request.response\n fail\n\n end",
"def user\n name = params[:name]\n number = params[:number]\n mail = params[:mail]\n id = params[:id]\n mail = \"#{mail}@gionee.com\" if mail.present? && mail.exclude?(\"@\")\n\n scope = User.all\n scope = scope.where(:id => id) if id.present?\n scope = scope.like(name) if name.present?\n scope = scope.where(:empId => number) if number.present?\n scope = scope.joins(:email_addresses).where(:email_addresses => {:address => mail}) if mail.present?\n\n users = scope.count == User.all.count ? [] : scope.limit(30)\n hash = users.map do |user|\n {\n :name => user.name,\n :id => user.id,\n :global_id => user.login,\n :number => user.empId,\n :mail => user.mail,\n :dept => user.dept_name,\n :dept_id => user.dept.try(:id)\n }\n end\n render :json => hash\n end",
"def get_user\n if params[:email].nil?\n render json: current_user,\n except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ]\n }\n }\n else\n user = User.find_by email:(params[:email])\n unless user.nil?\n if current_user.has_admin_permission? AdminPermission::ALL\n render json: user,\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ],\n }\n }\n elsif current_user.has_admin_permission? AdminPermission::ORCHESTRA_ADMIN\n render json: user, except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n }\n }\n\n elsif current_user.has_admin_permission? \\\n AdminPermission::LIST_CORTEGE_APPLICATIONS || AdminPermission::APPROVE_CORTEGE_APPLICATIONS\n render json: user, except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n }\n elsif current_user.has_admin_permission? AdminPermission::LIST_FUNKIS_APPLICATIONS\n render json: user, except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ],\n }\n }\n else\n render json: user, except: [\n :created_at,\n :updated_at,\n :permissions\n ]\n end\n else\n render :status => '404', :json => {:message => 'Användare kunde inte hittas'}\n end\n end\n end",
"def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def users\n get('get_users')\n end",
"def lookup\n respond_to do |format|\n format.json { render json: Core::UserLookup.new(view_context) }\n end\n end",
"def users(params = {})\n make_get_request('/account/users', params)\n end",
"def search_for_user_email(username) # :yields: JSON\n begin\n if @@app_token == nil\n raise \"Authentication not provided\"\n end\n uri=URI.parse(@uri_builder.get_user_contents(Api_options::USER::EMAIL,username:username, app_token:@@app_token))\n @uri_builder=nil\n\n HttpHandler.create_http uri\n\n response=HttpHandler.get_response(@@http,uri)\n @response_status=true\n return response\n\n end\n\n\n\n\n\n end",
"def get_users\r\n # Prepare query url.\r\n _path_url = '/users'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| User.from_hash(element) }\r\n end",
"def all_users()\n @endpoint = \"/users.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"users\"].sort_by { |user| user[\"lastname\"] }\n end",
"def index\n if params[:email].blank?\n @users = User.all\n else\n @user = User.find_by_email(params[:email])\n if !@user.blank?\n redirect_to user_path(@user, format: :json)\n else\n render :json => { :id => \"0\"}\n end\n end\n end",
"def index\n users = User.all\n json_response(users)\n end",
"def user_report\n user = User.find_by_username(params[:username])\n raise Discourse::InvalidParameters.new(:username) if !user\n\n ignored_ids = DiscourseFingerprint.get_ignores(user)\n\n fingerprints =\n Fingerprint\n .where(user: user)\n .where.not(value: FlaggedFingerprint.select(:value).where(hidden: true))\n .order(updated_at: :desc)\n\n user_ids =\n Fingerprint\n .matches\n .where(value: fingerprints.pluck(:value))\n .to_h { |match| [match.value, match.user_ids - [user.id]] }\n\n users = User.where(id: user_ids.values.flatten.uniq).or(User.where(id: ignored_ids))\n\n render json: {\n user: BasicUserSerializer.new(user, root: false),\n ignored_ids: ignored_ids,\n fingerprints:\n serialize_data(fingerprints, FingerprintSerializer, scope: { user_ids: user_ids }),\n users: users.map { |u| [u.id, BasicUserSerializer.new(u, root: false)] }.to_h,\n }\n end",
"def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end",
"def index\n @users = User.order_by(last_name: :desc)\n if @users\n render json: Oj.dump(json_for(@users, include: ['phones', 'cards'], meta: meta), mode: :compat)\n else\n return head :unauthorized\n end\n end",
"def get_by_id\n \n # the user_id param comes from our route\n user = User.find(params[:user_id])\n \n if user\n render json: user, status: :ok\n else\n render json: { errors: 'User not found' }, status: :not_found\n end\n end",
"def users(params = {})\n response = get('users/lookup.json', params)\n response.map {|user| Croudia::Object::User.new(user) }\n end",
"def user(user_id)\n response = connection.get do |req|\n req.url \"/user/#{user_id}\", simple_params\n end\n response.body[0]\n end",
"def fremont_users\n\ttmp = Array.new\n\tres = Array.new\n\ti = 0\n\twhile (tmp = TOKEN.get('/v2/campus/7/users', params: { page: i, per_page: 100 }).parsed).length > 0\n\t\tputs 'user request page is ' + i.to_s\n\t\ttmp.each do |page|\n\t\t\tres.push(page)\n\t\tend\n\t\ti += 1\n\tend\n\treturn res\nend",
"def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def index\n user= User.all\n render json: {users:user}\n end",
"def show\n user = User.friendly.find(params[:user_id]) \n render json: user\n end",
"def users\n result_hash['usr']\n end",
"def index\n users = User.all\n # cheer_ups = CheerUp.all\n render json: users\n end",
"def manage_users\n \t@users = User.all\n\n \trespond_to do |format|\n format.json {\n render :json => @users.as_json(:only => [:id, :username, :firstname, :lastname, :email], :methods => [:avatar_url])\n }\n format.html {\n render 'manage_users'\n }\n end\n end",
"def get_user_data(user_name)\n puts \"Please wait was your profile data is retrieved\"\n response = Net::HTTP.get_response(\"teamtreehouse.com\", \"/#{user_name}.json\")\n user_data = JSON.parse(response.body)\n puts \"Data retrieved!\"\n return user_data\nend",
"def show\n user = User.select(:id, :username, :email).find(params[:id])\n render :json => user\n end",
"def mf_api_get_user_info\n\n # Get the user from the DB\n user = User.find(params[:user_id])\n\n # If no user, return error response\n unless user\n response = {\n success: false,\n message: 'User not found'\n }\n\n render json: response and return\n end\n\n # Create User Info Response\n response = {\n success: true,\n message: 'User Info successfully retrieved',\n user_id: user.id,\n user_infusionsoft_id: user.clientid,\n user_first_name: user.first_name,\n user_last_name: user.last_name,\n user_email: user.email,\n }\n\n # Return success response\n render json: response\n\n end",
"def index\n return permission_denied unless \\\n (params[:id].to_s == @current_user.id.to_s) || \n (params[:email].to_s == @current_user.email.to_s)\n\n @users = User.where(params.permit(:id, :email))\n\n if @users\n render status: :ok,\n json: @users.as_json\n else\n render status: :not_found,\n json: {\n error: \"Users not found\"\n }\n end\n end",
"def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end",
"def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end",
"def get_user(id)\n @client.raw('get', \"/config/users/#{id}\")\n end",
"def index\n r = @api.get_users\n response = JSON.parse(r.body)\n if r.code == 200\n @users = response\n else\n redirect_to login_sign_in_admin_path, alert: response['message']\n end\n end",
"def getUserProfile(uid)\r\n uri = sprintf(\"/api/v1/users/%d/profile\",uid)\r\n dbg(uri)\r\n profile = $canvas.get(uri)\r\n return profile\r\nend",
"def getUserProfile(uid)\r\n uri = sprintf(\"/api/v1/users/%d/profile\",uid)\r\n dbg(uri)\r\n profile = $canvas.get(uri)\r\n return profile\r\nend",
"def userbyemail\n user = User.find_by_email(params[:email])\n \n if user\n render json: user\n else\n render json: { :success => false }\n end\n end",
"def fetch_users\n\n result = CacheManagement::ClientApiCredentials.new([@client_id]).fetch[@client_id]\n return validation_error(\n 'cum_lu_6',\n 'invalid_api_params',\n ['invalid_client_id'],\n GlobalConstant::ErrorAction.default\n ) if result.blank?\n\n if is_xhr_request?\n\n ost_sdk = OSTSdk::Saas::Services.new(\n api_key: result[:api_key],\n api_secret: result[:api_secret],\n api_base_url: GlobalConstant::SaasApi.v1dot1_base_url,\n api_spec: false\n )\n\n @ost_sdk_obj = ost_sdk.services.users\n\n list_params = {}\n list_params[:page_no] = @page_no unless @page_no.nil?\n list_params[:order_by] = @order_by unless @page_no.nil?\n list_params[:order] = @order unless @page_no.nil?\n list_params[:airdropped] = @airdropped unless @airdropped.nil?\n\n service_response = @ost_sdk_obj.list(list_params)\n\n return service_response unless service_response.success?\n\n @api_response_data = service_response.data\n\n else\n\n ost_sdk = OSTSdk::Saas::Services.new(\n api_key: result[:api_key],\n api_secret: result[:api_secret],\n api_base_url: GlobalConstant::SaasApi.v1dot1_base_url,\n api_spec: true\n )\n\n @ost_spec_sdk_obj = ost_sdk.services.users\n api_spec_service_response = @ost_spec_sdk_obj.create({name: \"{{uri_encoded name}}\"})\n\n return api_spec_service_response unless api_spec_service_response.success?\n\n api_spec_service_response.data[:request_uri].gsub!(GlobalConstant::SaasApi.base_url, GlobalConstant::SaasApi.display_only_base_url)\n\n @api_response_data[:api_console_data] = {\n user: {\n create: api_spec_service_response.data\n }\n }\n\n end\n\n success\n\n end",
"def show\n render json: get_full_user_details(user), status: :ok\n rescue => e\n log_and_render_users_controller_error(e, \"get user details failed\")\n end",
"def index\n users = User.all\n render json: { users: users }, status: :ok\n end",
"def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end",
"def user\n hash = {\n provider: 'josh_id',\n id: current_user.id.to_s,\n info: {\n email: current_user.email,\n username: current_user.username,\n #first_name: current_user.first_name,\n }\n }\n\n render json: hash.to_json\n end",
"def show\n @user = User.where('email = ?',params[:email]).take\n render json: @user\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end",
"def get_users(options)\n @client.raw('get', '/config/users', options)\n end",
"def users\n channel = Channel.find(params[:id])\n users = ChannelJoined.where(channel_id: params[:id])\n return json_response({\n users: users.map{|j| j.user}\n })\n end",
"def byUid\n @user = User.find(:all, :conditions => [ \"uid = ?\" , params[:id]])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def users\n puts \"SEARCH USERS\"\n @users = User.search(params[:q])\n puts \"SEARCH USERS COUNT:#{@users.count}\"\n render :json => @users.as_json(:current_user => current_user)\n end",
"def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end",
"def get\n new_user = User.new(user_params)\n @user = User.find_by(number: new_user.number)\n \n if not @user.nil?\n render json: @user\n else \n new_user.save\n render json: new_user\n end\n end",
"def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end",
"def show\n @users = User.all\n json_response(@users)\n end",
"def user1\n if user = User.where(\"lower(users.login) = ?\", params[:login].downcase).first\n result = {\n :id => user.id,\n :username => user.login,\n :name => user.name,\n :avatar_url => user.avatar_url,\n :location => user.location\n }\n render json: result\n else\n head :not_found\n end\n end",
"def show_user\n usernames = params.require(:usernames)\n\n identities = Hash[User.where(username: usernames).map { |u| [u.username, u.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]] }]\n\n render json: identities\n end",
"def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end",
"def index\n @event = Event.find(params[:id])\n @users = @event.users\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n respond_with ApidUser.all\n end",
"def main_users\n\t\t@main_users = ParseGoLink.main_users\n\t\trender json: @main_users\n\tend",
"def show_disposisi_user\n\t\t@user = Disposisi.where(user_id: params[:user_id]).order(id: :desc).limit(20)\n\t\trender json: @user\t\n\tend",
"def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end",
"def index\n\t\tif params.has_key?(:email)\n\t\t\t@user = User.where(\"email = ?\", params[:email]).first\n\t\t\trender json: @user.to_json\n\t\telse\n\t\t\thead :no_content \n\t\tend\n\tend",
"def json_show_user_profile_by_user_id\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.json { render json: @user.as_json(only:[:email,:username]) }\n end\n end",
"def index\r\n users = User.all\r\n render json: users\r\n end"
] |
[
"0.6822484",
"0.6801907",
"0.65722764",
"0.6542782",
"0.64431804",
"0.6437672",
"0.6422124",
"0.64149046",
"0.6385286",
"0.63612884",
"0.6361115",
"0.6361115",
"0.63608205",
"0.63596237",
"0.63580936",
"0.6351446",
"0.635084",
"0.6350172",
"0.6340591",
"0.6300943",
"0.62991357",
"0.6281189",
"0.62800825",
"0.62766236",
"0.6245489",
"0.62360346",
"0.62334275",
"0.6213489",
"0.6213018",
"0.62122333",
"0.62066567",
"0.61982167",
"0.6192551",
"0.61816937",
"0.6173116",
"0.61694366",
"0.6128096",
"0.6119559",
"0.6117029",
"0.6115572",
"0.6105741",
"0.6099253",
"0.6098132",
"0.608829",
"0.60841507",
"0.60824674",
"0.60750026",
"0.6071678",
"0.60664237",
"0.606162",
"0.604164",
"0.603927",
"0.6031502",
"0.60265493",
"0.6022734",
"0.60176486",
"0.6017026",
"0.60163265",
"0.6000066",
"0.59909815",
"0.59806734",
"0.59797055",
"0.5979364",
"0.5974549",
"0.5974323",
"0.59725565",
"0.59584457",
"0.5957555",
"0.5950096",
"0.59475327",
"0.59471506",
"0.59368587",
"0.59368587",
"0.59368545",
"0.59340334",
"0.59323555",
"0.59230274",
"0.59129983",
"0.5905478",
"0.5905455",
"0.59027183",
"0.5902296",
"0.5901758",
"0.5900025",
"0.58994687",
"0.5897919",
"0.5897758",
"0.5890788",
"0.5888236",
"0.5880912",
"0.58762306",
"0.58739775",
"0.5872591",
"0.5870537",
"0.58657205",
"0.5864718",
"0.5862193",
"0.586207",
"0.58615565",
"0.58584774"
] |
0.7289374
|
0
|
GET /euclid_users/new GET /euclid_users/new.json
|
def new
@euclid_user = EuclidUser.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @euclid_user }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @user = user.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n end\n end",
"def new2\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new(:organization_id => current_org.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @users = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users }\n end\n end",
"def new\n \n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n \n end",
"def new\n @users = User.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n @action = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n render json: @user\n end",
"def new\n # When a http GET request to '/users/new' is received, have it render:\n # a view file with an empty form to create a new user.\n end",
"def new\n @user = User.new\n render :json => @user\n end",
"def new\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user_id = UserId.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_id }\n end\n end",
"def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end"
] |
[
"0.7714887",
"0.77041",
"0.7681287",
"0.7508355",
"0.7479379",
"0.7457338",
"0.74127156",
"0.7396769",
"0.73927766",
"0.7378929",
"0.73718935",
"0.7359137",
"0.73421896",
"0.73421896",
"0.72694767",
"0.7265147",
"0.7265147",
"0.7265147",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225",
"0.7261225"
] |
0.78537786
|
0
|
POST /euclid_users POST /euclid_users.json
|
def create
@euclid_user = EuclidUser.new(params[:euclid_user])
@euclid_user.proximity = "distant";
respond_to do |format|
if @euclid_user.save
format.html { redirect_to @euclid_user, notice: 'Euclid user was successfully created.' }
format.json { render json: @euclid_user, status: :created, location: @euclid_user }
else
format.html { render action: "new" }
format.json { render json: @euclid_user.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end",
"def new\n @euclid_user = EuclidUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @euclid_user }\n end\n end",
"def mf_api_manually_add_user\n\n # Create new User\n user = User.new\n\n # Populate User\n user.clientid = params[:client_id]\n user.email = params[:email]\n\n user.save\n\n response = {\n success: true,\n message: 'New User Created!'\n }\n\n render json: response\n\n end",
"def create_user(options = {})\n post :create, {:user => { :name => 'quire', :point_value => \"2\", :login => 'quire', :email => 'quire@example.com',\n :password => 'quire', :password_confirmation => 'quire' }.merge(options)}, {:user_id => \"1\"}\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def user_new_user(email, password, username, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserApi#user_new_user ...\"\n end\n\n # verify the required parameter 'email' is set\n fail \"Missing the required parameter 'email' when calling user_new_user\" if email.nil?\n\n # verify the required parameter 'password' is set\n fail \"Missing the required parameter 'password' when calling user_new_user\" if password.nil?\n\n # verify the required parameter 'username' is set\n fail \"Missing the required parameter 'username' when calling user_new_user\" if username.nil?\n\n # resource path\n path = \"/user\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n form_params[\"email\"] = email\n form_params[\"password\"] = password\n form_params[\"username\"] = username\n form_params[\"firstname\"] = opts[:'firstname'] if opts[:'firstname']\n form_params[\"lastname\"] = opts[:'lastname'] if opts[:'lastname']\n form_params[\"acceptsTOS\"] = opts[:'accepts_tos'] if opts[:'accepts_tos']\n form_params[\"referrerID\"] = opts[:'referrer_id'] if opts[:'referrer_id']\n form_params[\"country\"] = opts[:'country'] if opts[:'country']\n\n # http body (model)\n post_body = nil\n\n\n auth_names = []\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'User')\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserApi#user_new_user. Result: #{result.inspect}\"\n end\n return result\n end",
"def user_create(username, email, password, tenant_id)\n\t\n\t\tuser = {\"user\" => {\"name\" => username, \"email\" => email, \"enabled\" => true, \"password\" => password, \"tenantid\" => tenant_id}}\n\t\n\t\tjson_string = JSON.generate(user)\n\t\n\t\tpost_call = Curl::Easy.http_post(\"#{@ip_address}:#{@port_2}/v2.0/users\", json_string\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['Content-Type'] = 'application/json'\n\t\tend\n\t\t\t\t\t\t\t\t\t \n\t\tparsed_json = JSON.parse(post_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end",
"def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end",
"def postUser( email, user_id, first_name, last_name, active, trust, creation_date, user_type, social_network, social_network_id, reseller_admin_masheryid, group_id, admin_upgrader)\n params = Hash.new\n params['email'] = email\n params['user_id'] = user_id\n params['first_name'] = first_name\n params['last_name'] = last_name\n params['active'] = active\n params['trust'] = trust\n params['creation_date'] = creation_date\n params['user_type'] = user_type\n params['social_network'] = social_network\n params['social_network_id'] = social_network_id\n params['reseller_admin_masheryid'] = reseller_admin_masheryid\n params['group_id'] = group_id\n params['admin_upgrader'] = admin_upgrader\n return doCurl(\"post\",\"/user\",params)\n end",
"def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end",
"def add_user(name, value)\n self.class.post(\"/users/#{name}\",\n body: value,\n headers: {\n 'Content-Type' => 'application/json; charset=UTF-8',\n Connection: 'keep-alive',\n Accept: 'application/json, text/plain, */*'\n })\n end",
"def save_user\n client = create_db_client\n client.query(\"INSERT INTO users(name, email, password, bio) VALUES('#{@name}', '#{@email}', '#{@password}', '#{@bio}')\")\n \n id = client.last_id\n rawData = client.query(\"SELECT * FROM users WHERE id='#{id}'\")\n users = Array.new\n rawData.each do |data|\n user = {:id => data[\"id\"], :name => data[\"name\"] ,:email => data[\"email\"], :password => data[\"password\"], :bio => data[\"bio\"]}\n users << user\n end\n response = Response.new('success', 'success input user', users)\n return response.response_api\n end",
"def sign_up(user = {})\n if @api_host.present? && user.present?\n begin\n request_url = @api_host + \"/api/v1/sign_up\"\n payload = Hash.new\n payload[:user] = user\n request_headers = { \"Content-Type\" => \"application/json\" }\n response = RestClient.post(request_url, payload.to_json, request_headers)\n result = JSON.parse(response.body)\n Rails.logger.info \"===== sign up result ===== #{result} =====\"\n result\n rescue RestClient::ExceptionWithResponse => e\n error = JSON.parse(e.response)\n Rails.logger.warn \"===== sign up errors ===== #{error} =====\"\n error\n end\n end\n end",
"def create_user\n @user = User.new(user_params)\n @user.role = :user\n if @user.save\n correct_cs_entries @user\n correct_ci_entries @user\n render 'objects/user.json'\n else\n @msg = \"Error in generating user\"\n @details = @user.errors\n render \"objects/msg.json\", status: :bad_request\n end\n end",
"def create\n @jam_circle = JamCircle.new(jam_circle_params)\n @jam_circle.user_id = @user.id\n @jam_circle.users << @user\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.save\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :created, location: @jam_circle }\n else\n format.html { render :new }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = @application.users.create(user_params)\n\n if @user.valid?\n render json: @user, status: :created, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tif(request.method == \"OPTIONS\")\n\t\t\trespond({status: 1})\n\t\telsif request.method == \"POST\"\n\t\t\tuser = parse_user(params)\n\t\t\tu = User.find_by(jive_id: user[:jive_id])\n\t\t\tif !u\n\t\t\t\tu = User.new(jive_id: user[:jive_id], \n\t\t\t\t\t\t\t employee_id: user[:employee_id], \n\t\t\t\t\t\t\t client_id: user[:client_id],\n\t\t\t\t\t\t\t name: user[:name]\t\n\t\t\t\t\t\t\t )\n\t\t\t\tif u.valid?\n\t\t\t\t\tu.save\n\t\t\t\t\tresponse = { status: 0, message: \"User Created\", user: u }\n\t\t\t\telse\n\t\t\t\t\tresponse = { status: 1, error: \"Error: #{u.errors.full_messages}\" }\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif !params[:client].blank?\n\t\t\t\t\tu = update_user_client(params)[:user]\n\t\t\t\tend\n\t\t\t\tresponse = { status: 0, message: \"User Exists.\", user: u }\n\t\t\tend\n\t\t\trespond(response)\n\t\tend\n\tend",
"def create\n @user = User.new(form_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: { users: @user }, status: :created }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user.children.create(params[:user].merge :email => \"design+parent_id#{current_user.id}_child_count#{current_user.children.count + 1}@newint.com.au\")\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_path(current_user), notice: 'User was successfully created.' }\n format.json { render json: [:institution, @user], status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_user(email_ids)\n options = {\n :query => {\n 'ZOHO_ACTION' => 'ADDUSER',\n 'ZOHO_EMAILS' => email_ids,\n }\n }\n\n send_request get_user_uri, 'post', options\n end",
"def new_user(username, password, full_name, email)\n representation = form_encoded({ \"user[name]\" => username,\n \"user[password]\" => password,\n \"user[full_name]\" => full_name,\n \"user[email]\" => email }) \n puts representation\n begin\n response = open(@service_root + '/users', :method => :post, \n :body => representation)\n puts \"User #{username} created at #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == \"409\" # Conflict\n puts \"Sorry, there's already a user called #{username}.\"\n else\n raise e\n end\n end\n end",
"def add_user(opts)\n generated_pass = rand(10E10).to_s\n data = {\n :login => opts[:login] || opts[:email],\n :firstName => opts[:first_name] || 'FirstName',\n :lastName => opts[:last_name] || 'LastName',\n :password => opts[:password] || generated_pass,\n :verifyPassword => opts[:password] || generated_pass,\n :email => opts[:email] || opts[:login]\n }\n\n # Optional authentication modes\n tmp = opts[:authentication_modes]\n if tmp\n if tmp.is_a? Array\n data[:authenticationModes] = tmp\n elsif tmp.is_a? String\n data[:authenticationModes] = [tmp]\n end\n end\n\n # Optional company\n tmp = opts[:company_name]\n tmp = opts[:company] if tmp.nil? || tmp.empty?\n data[:companyName] = tmp if tmp && !tmp.empty?\n\n # Optional country\n tmp = opts[:country]\n data[:country] = tmp if tmp && !tmp.empty?\n\n # Optional phone number\n tmp = opts[:phone]\n tmp = opts[:phone_number] if tmp.nil? || tmp.empty?\n data[:phoneNumber] = tmp if tmp && !tmp.empty?\n\n # Optional position\n tmp = opts[:position]\n data[:position] = tmp if tmp && !tmp.empty?\n\n # Optional sso provider\n tmp = opts[:sso_provider]\n data['ssoProvider'] = tmp if tmp && !tmp.empty?\n\n # Optional timezone\n tmp = opts[:timezone]\n data[:timezone] = tmp if tmp && !tmp.empty?\n\n c = client(opts)\n\n # TODO: It will be nice if the API will return us user just newly created\n url = \"/gdc/account/domains/#{opts[:domain]}/users\"\n response = c.post(url, :accountSetting => data)\n\n url = response['uri']\n raw = c.get url\n\n # TODO: Remove this hack when POST /gdc/account/domains/{domain-name}/users returns full profile\n raw['accountSetting']['links'] = {} unless raw['accountSetting']['links']\n raw['accountSetting']['links']['self'] = response['uri'] unless raw['accountSetting']['links']['self']\n\n c.create(GoodData::Profile, raw)\n end",
"def create\n r = @api.create_user(user_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to users_url, alert: response['message']}\n end\n end\n end",
"def add_user(user_data, name = nil, opts = { :client => GoodData.connection })\n generated_pass = rand(10E10).to_s\n domain_name = name || user_data[:domain]\n user_data = user_data.to_hash\n data = {\n :login => user_data[:login] || user_data[:email],\n :firstName => user_data[:first_name] || 'FirstName',\n :lastName => user_data[:last_name] || 'LastName',\n :password => user_data[:password] || generated_pass,\n :verifyPassword => user_data[:password] || generated_pass,\n :email => user_data[:email] || user_data[:login]\n }\n\n # Optional authentication modes\n tmp = user_data[:authentication_modes]\n if tmp\n if tmp.is_a? Array\n data[:authenticationModes] = tmp\n elsif tmp.is_a? String\n data[:authenticationModes] = [tmp]\n end\n end\n\n # Optional company\n tmp = user_data[:company_name]\n tmp = user_data[:company] if tmp.nil? || tmp.empty?\n data[:companyName] = tmp if tmp && !tmp.empty?\n\n # Optional country\n tmp = user_data[:country]\n data[:country] = tmp if tmp && !tmp.empty?\n\n # Optional phone number\n tmp = user_data[:phone]\n tmp = user_data[:phone_number] if tmp.nil? || tmp.empty?\n data[:phoneNumber] = tmp if tmp && !tmp.empty?\n\n # Optional position\n tmp = user_data[:position]\n data[:position] = tmp if tmp && !tmp.empty?\n\n # Optional sso provider\n tmp = user_data[:sso_provider]\n data['ssoProvider'] = tmp if tmp && !tmp.empty?\n\n # Optional timezone\n tmp = user_data[:timezone]\n data[:timezone] = tmp if tmp && !tmp.empty?\n\n c = client(opts)\n\n # TODO: It will be nice if the API will return us user just newly created\n begin\n url = \"/gdc/account/domains/#{domain_name}/users\"\n response = c.post(url, :accountSetting => data)\n rescue RestClient::BadRequest\n raise GoodData::UserInDifferentDomainError, \"User #{data[:login]} is already in different domain\"\n end\n\n url = response['uri']\n raw = c.get url\n\n # TODO: Remove this hack when POST /gdc/account/domains/{domain-name}/users returns full profile\n raw['accountSetting']['links'] = {} unless raw['accountSetting']['links']\n raw['accountSetting']['links']['self'] = response['uri'] unless raw['accountSetting']['links']['self']\n c.create(GoodData::Profile, raw)\n end",
"def create\n user = User.new(\n username: user_params[:username],\n password: user_params[:password])\n if user.save\n create_example_collection(user)\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: user.errors.full_messages}\n end\n end",
"def create\n @ngo_user = NgoUser.new(ngo_user_params)\n @ngo_user.user_id = @current_user.id\n\n respond_to do |format|\n if @ngo_user.save\n format.html { redirect_to users_path, notice: 'Ngo user was successfully created.' }\n format.json { render :show, status: :created, location: @ngo_user }\n else\n format.html { render :new }\n format.json { render json: @ngo_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n group_ids = params[\"group_id\"]\n org_id = params[:organization_id]\n @user = User.new(full_name: params[:full_name], password: params[:password], password_confirmation: params[:password], email: params[:email], status: params[:status], staff_number: params[:employee_id], career_path: params[:career_path], team_leader_id: nil)\n @user.user_group_ids = group_ids\n @user.organization_id = org_id\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n end",
"def users_post\n params = Rack::Request.new(@env).POST\n phone = params['phone']\n key = params['key']\n\n if phone_valid?(phone) && uuid_valid?(key)\n # Validate picture_id, first_name, last_name, and email\n picture_id = params['picture_id']\n error = picture_id_invalid_response!(picture_id)\n return error if error\n\n first_name = params['first_name']\n error = name_invalid_response!('First', first_name)\n return error if error\n\n last_name = params['last_name']\n error = name_invalid_response!('Last', last_name)\n return error if error\n\n email = params['email']\n error = email_invalid_response!(email)\n return error if error\n\n $pg.with do |pg|\n pg.exec_params('SELECT * FROM users_post($1, $2, $3, $4, $5)', [phone, key, first_name, last_name, email]) do |r|\n if r.num_tuples == 1\n user_id = r.getvalue(0, 0)\n body = {access_token: build_access_token(user_id, key)}\n if picture_id\n fields = Aws::S3::Resource.new.bucket('acani-chats').presigned_post({\n acl: 'public-read',\n content_length_range: 0..3145728,\n content_type: 'image/jpeg',\n key: \"users/#{user_id}/#{picture_id}.jpg\"\n }).fields\n body[:fields] = fields\n end\n return [201, body.to_json]\n end\n end\n end\n end\n set_www_authenticate_header\n [401, '{\"message\":\"Incorrect phone or key.\"}']\n end",
"def create\n @user = User.new(\n first_name: params[:first_name],\n last_name: params[:last_name],\n birth_date: params[:birth_date],\n height: params[:height],\n weight: params[:weight],\n user_name: params[:user_name],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n facebook_url: params[:facebook_url],\n twitter_url: params[:twitter_url],\n instagram_url: params[:instagram_url],\n address: params[:address],\n email: params[:email]\n ) \n if @user.save!\n render 'successful.json.jb', status: :created\n else\n render 'unsuccessful.json.jb', status: :bad_request\n end\n end",
"def create\n user = User.create(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end",
"def create_user_in_canvas(user, username, timezone = nil, docusign_template_id = nil)\n user_student_id = nil\n enrollment = Enrollment.find_by_user_id(user.id)\n user_student_id = enrollment.student_id unless enrollment.nil?\n\n # the v1 is API version, only one option available in Canvas right now\n # accounts/1 refers to the Beyond Z account, which is the only one\n # we use since it is a custom installation.\n request = Net::HTTP::Post.new('/api/v1/accounts/1/users')\n request.set_form_data(\n 'access_token' => Rails.application.secrets.canvas_access_token,\n 'user[name]' => user.name,\n 'user[short_name]' => user.first_name,\n 'user[sortable_name]' => \"#{user.last_name}, #{user.first_name}\",\n 'user[skip_registration]' => true,\n 'user[time_zone]' => timezone,\n 'user[docusign_template_id]' => docusign_template_id,\n 'pseudonym[unique_id]' => username,\n 'pseudonym[send_confirmation]' => false,\n 'communication_channel[type]' => 'email',\n 'communication_channel[address]' => user.email,\n 'communication_channel[skip_confirmation]' => true,\n 'communication_channel[confirmation_url]' => true,\n 'pseudonym[sis_user_id]' => \"BVID#{user.id}-SISID#{user_student_id}\"\n )\n response = open_canvas_http.request(request)\n\n new_canvas_user = JSON.parse response.body\n\n # this will be set if we actually created a new user\n # reasons why it might fail would include existing user\n # already having the email address\n\n # Not necessarily an error but for now i'll just make it throw\n raise \"Couldn't create user #{username} <#{user.email}> in canvas #{response.body}\" if new_canvas_user['id'].nil?\n\n user.canvas_user_id = new_canvas_user['id']\n\n # Not necessary (and didn't seem to actually work?) since we changed the code\n # on the Canvas side to mark them registered if skip_confirmation is specified.\n #if new_canvas_user['confirmation_url']\n # request = Net::HTTP::Get.new(new_canvas_user['confirmation_url'])\n # open_canvas_http.request(request)\n #end\n\n user\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create_user(user,pass,firstname,lastname,sso_provider)\n\n # test_user = 'jiri.tobolka+kbc@bizztreat.com'\n # pass = 'akbvgdrz77'\n # firstname = 'J'\n # lastname = 'T'\n\n values = \"{\\\"writerId\\\": \\\"#{@writer_id}\\\", \\\"email\\\": \\\"#{user}\\\", \\\"password\\\": \\\"#{pass}\\\", \\\"firstName\\\": \\\"#{firstname}\\\", \\\"lastName\\\": \\\"#{lastname}\\\", \\\"ssoProvider\\\": \\\"#{sso_provider}\\\"}\"\n\n headers = {:x_storageapi_token => @kbc_api_token, :accept => :json, :content_type => :json}\n\n begin\n response = RestClient.post \"#{@api_endpoint}/users\", values, headers\n\n rescue Exception => msg\n\n puts msg\n #manager.clean_csv(variable_file,message)\n #manager.set_existing_variable_bulk(variable_file,$gd_pid)\n #puts message\n end\n\n return response\n\n end",
"def user_params\n params.require(:user).permit(:name, :avatar_url, :phone, :city, :address, :group_id, :user_type_id, :email, elective_ids:[], event_report_ids:[])\n end",
"def create\n @user = User.new(user_params)\n @user.email = params[:email].downcase\n if @user.save\n render json: @user, status: 200\n else\n render json: { errors: @user.errors.full_messages }, status: 400\n end\n end",
"def create\n @user = User.find_by_external_id(user_params[:external_id])\n\n if @user.nil?\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.json { render json: {user: @user}, status: 200 }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.json { render json: {user: @user}, status: 200 }\n end\n end\n\n end",
"def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n render json: response, status: :internal_server_error\n end\n end",
"def create_usr\n user_reg = MobileUser.api(params[:usr_crt])\n render json: {errorMessage: user_reg[0], status: user_reg[1]}, status: 201\n end",
"def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params(params))\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(\n first_name: params[:first_name],\n last_name: params[:last_name],\n email: params[:email],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n gender: params[:gender],\n birthday: params[:birthday],\n address: params[:address],\n phone_number: params[:phone_number],\n currently_doing: params[:currently_doing],\n education: params[:education],\n references: params[:references],\n additional_info: params[:additional_info],\n image_url: params[:image_url],\n parents: params[:parents],\n siblings: params[:siblings],\n shul: params[:shul],\n summers: params[:summers],\n height: params[:height],\n shadchan_info: params[:shadchan_info],\n looking_for: params[:looking_for],\n )\n if @user.save\n render json: { message: \"User created successfully\" }, status: :created\n else\n render json: { errors: @user.errors.full_messages }, status: :bad_request\n end\n end",
"def create\n @event = Event.new(event_params)\n @event.host_id = current_user.id\n\n\n respond_to do |format|\n if @event.save\n\n @event.users << User.find(@event.host_id)\n unless params[:users].nil?\n params[:users].each do |u|\n @event.users << User.find(u)\n end\n end\n\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n @users = User.all\n end\n end\n end",
"def create\n @user = User.new(user_params)\n @user.annual = @user.user_id.slice(1..4)\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'ユーザーの作成が完了しました。' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tresp = {} \n user = User.create(user_params)\n \tif user.valid?\n if user.save\n return render :json => user.as_json\n end\n end\n render json: user.errors.full_messages \n\tend",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\r\n\r\n # Make a copy of the user params\r\n user_params = (params[:user]).clone\r\n\r\n unless ApplicationHelper.validate_key(request.headers[\"Validation-Key\"])\r\n # If the validation key is there, then this is a test app talking to us, so\r\n # accept whatever secret key is passed in. Otherwise, generate a random key.\r\n user_params.merge!(:secretkey => SecureRandom.uuid)\r\n end\r\n\r\n # initialize bucks to be 200 and member to be false\r\n user_params.merge!(:bucks => 200, :membertime => nil)\r\n\r\n # handle fb friends case\r\n friends = user_params.delete(:fb_friends)\r\n if friends\r\n fbid = user_params[:fbid]\r\n available_friends = fb_friends_helper(fbid, friends)\r\n\r\n user_params.merge!(:fb_friends => available_friends)\r\n end\r\n\r\n # Create the new user\r\n @user = User.new(user_params)\r\n\r\n respond_to do |format|\r\n if @user.save\r\n\r\n # Update bucks for the user for this week\r\n start_date = Time.now.beginning_of_week.to_date\r\n update_bucks_lb(@user.id, user_params[:bucks], start_date)\r\n\r\n log_event(:user, :created, user_params)\r\n\r\n # Be cautious about creating users through the website. The general case is\r\n # that users are only ever created via the JSON API. The website interface\r\n # should only be used for debugging purposes.\r\n format.html { redirect_to @user, notice: 'User was successfully created.' }\r\n format.json { render json: @user.as_json(:only => [:id, :fbid, :membertime, :bucks, :email, :secretkey]) }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json {\r\n create_error(:unprocessable_entity, :post, user_params, @user.errors)\r\n }\r\n end\r\n end\r\n end",
"def create_user(body)\n post 'create_user', body\n end",
"def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def user_params\n params.require(:user).permit(:uid).merge(provider: \"cas\", email: \"#{params[:user][:uid]}@princeton.edu\")\n end",
"def create\n @user = User.new(params[:user])\n find_languages_and_countries\n @user.is_admin = false\n GivePoints.add_on_create(@user)\n respond_to do |format|\n if @user.save\n format.html { redirect_to confirmation_has_been_sent_path, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n format.html { render :controller => \"public\", :action => \"public_signin\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_user(uid, params={})\n params.merge!(default_params)\n params['pio_uid'] = uid\n extract_latlng(params)\n @connection.post(:users, params).body\n end",
"def create\n user_response = API::V1::Users.authenticate params.as_json\n if user_response.success?\n json = HashWithIndifferentAccess.new(user_response.parsed_response)\n auth_response = API::V1::Auth.issue json[:data]\n respond_with auth_response.body, auth_response.code\n else\n respond_with nil, :unauthorized\n end\n end",
"def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end",
"def add_user_for_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/users\", args)\nend",
"def create_users(accountId, model) path = \"/api/v2/accounts/#{accountId}/users\"\n post(path, model, {}, AvaTax::VERSION) end",
"def get\n new_user = User.new(user_params)\n @user = User.find_by(number: new_user.number)\n \n if not @user.nil?\n render json: @user\n else \n new_user.save\n render json: new_user\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n render json: { user: @user, success: 'User registration successful' }\n else\n render json: { error: 'User registration unsuccessful' }\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: {status: \"Se creo el usuario\"}, status: :ok\n else\n render json: {status: \"Error al crear el usuario\", errors: user.errors }, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n @user.remote_ip = request.remote_ip\n\n response = Apis.get_imsi_ecgi(request.remote_ip)\nlogger.error '### ' + response.code.to_s\n \tif response.code != 200\n\t\tredirect_to new_user_path, notice: '해당 사용자가 등록되어 있지 않습니다.'\n\telse \n\t\txml_parser = Nori.new\n\n\t\tresult = xml_parser.parse(response.body)\n\t\t@user.imsi = result['BODY']['IMSI']\n\t\t@user.ecgi = result['BODY']['ECGI']\n\t\t\n\t\trespond_to do |format|\n\t\t\t\tif @user.save\n\t\t\t\t\tsign_in(@user)\n\t\t\t\t\tformat.html { redirect_to setting_path, notice: '가입을 축하합니다' }\n\t\t\t\t\tformat.json { render action: 'show', status: :created, location: @user }\n\t\t\t\telse\n\t\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\t\tend\n\t\tend\n\tend\n end",
"def register_api\n # begin\n email = \"not_provided#{User.last.present? ? User.last.id : 0}@not_provided.com\"\n password = 'not_provided'\n @user = User.find_by_device_token(register_api_params[:device_token])\n @user = User.find_by_email(email) if @user.blank?\n if @user.blank?\n user = @user\n @user = User.new(:email => email, :username => register_api_params[:username], :password => password, :device_token => register_api_params[:device_token], :lat => register_api_params[:lat], :lng => register_api_params[:lng])\n @user.save!\n # images = images_with_distance(@user, register_api_params[:distance])\n images = UserImage.where('user_id = ?', @user.id).order(\"created_at DESC\")\n images = add_likes(images)\n render :json => {:user => {:id => @user.id, :username => @user.username, :auth_token => @user.auth_token, :device_token => @user.device_token, :notification_count => @user.notification_count, :created_at => @user.created_at, :updated_at => @user.updated_at, :lng => @user.lng, :lat => @user.lat}, :images => images}\n else\n @user.update_attribute('lng', register_api_params[:lng].to_f)\n @user.update_attribute('lat', register_api_params[:lat].to_f)\n # images = images_with_distance(@user, register_api_params[:distance])\n images = UserImage.where('user_id = ?', @user.id).order(\"created_at DESC\")\n images = add_likes(images)\n render :json => {:user => {:id => @user.id, :username => @user.username, :auth_token => @user.auth_token, :device_token => @user.device_token, :notification_count => @user.notification_count, :created_at => @user.created_at, :updated_at => @user.updated_at, :lng => @user.lng, :lat => @user.lat}, :images => images}\n end\n # rescue Exception => e\n # error \"Please provide all required fields or Something went wrong.\"\n # end\n end",
"def create_user(user)\n open_canvas_http\n\n # the v1 is API version, only one option available in Canvas right now\n # accounts/1 refers to the Beyond Z account, which is the only one\n # we use since it is a custom installation.\n request = Net::HTTP::Post.new('/api/v1/accounts/1/users')\n request.set_form_data(\n 'access_token' => Rails.application.secrets.canvas_access_token,\n 'user[name]' => user.name,\n 'user[short_name]' => user.first_name,\n 'user[sortable_name]' => \"#{user.last_name}, #{user.first_name}\",\n 'user[terms_of_use]' => true,\n 'pseudonym[unique_id]' => user.email,\n 'pseudonym[send_confirmation]' => false\n )\n response = @canvas_http.request(request)\n\n new_canvas_user = JSON.parse response.body\n\n # this will be set if we actually created a new user\n # reasons why it might fail would include existing user\n # already having the email address\n\n # Not necessarily an error but for now i'll just make it throw\n raise \"Couldn't create user #{user.email} in canvas #{response.body}\" if new_canvas_user['id'].nil?\n\n user.canvas_user_id = new_canvas_user['id']\n\n user\n end",
"def create\n\t\t@user = User.new(users_params)\n\t\tif @user.save\n\t\t\tjson_response(@user, \"User is created Successfully.\")\n\t\telse\n\t\t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n\t\tend\t\t\n\tend",
"def create\n p \"-------user signup------\"\n user = User.new(user_params)\n user.skip_confirmation!\n if user.save\n data = { success: true, message: \"Your account registered.\" }\n else\n key, val = user.errors.messages.first\n data = { success: false, message: user.errors.full_messages.first }\n end\n render json: data\n end",
"def create\n\n up = user_params\n\n if up[:name].present?\n up[:first_name] = up[:name].split(' ')[0]\n up[:last_name] = up[:name].split(' ')[1]\n up.delete :name\n end\n @user = User.new(up)\n\n respond_to do |format|\n if @user.save\n # render json: {user: user, token: token}\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: api_user_url(@user)}\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user\n @user = User.new(user_params)\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tuserParams = params.require(:user).permit([:email, :password])\n\n\t\tuser = User.find_by_email(userParams[:email])\n\n\t\tif(user.nil?)\n\t\t\tuserParams[:password] = Digest::MD5.hexdigest(userParams[:password])\n\t\t\tuser = User.new userParams\n\t\t\tuser.save\n\t\t\trender json: { success: true}, :status => 200, callback: params[:callback]\n\t\telse\n\t\t\trender json: { success: false, reason: \"User already exists\", errno: -1 }, callback: params[:callback]\n\t\tend\n\tend",
"def create\n @user = User.new(name: user_params[:name], email: user_params[:email], end_date: user_params[:end_date])\n \n respond_to do |format|\n if @user.save\n user_params[:cycle_ids].reject(&:empty?).each_with_index do |id, index|\n role_id = user_params[:role_ids].reject(&:empty?)\n company_id = user_params[:company_ids].reject(&:empty?)\n CoUserRoleCycle.create(user_id: @user.id, cycle_id: id, role_id: role_id[index], company_id: company_id[index])\n end\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tnew_user = User.new(user_params)\n\t\tif new_user.save\n\t\t render status: 200, json: {\n\t\t \tstatus: 200,\n\t\t message:\"New User Created\",\n\t\t response: {\n\t\t name: new_user.name,\n\t\t email: new_user.email,\n\t\t id: new_user.id,\n\t\t facebook_id: new_user.facebook_id,\n\t\t device_id: new_user.device_id,\n\t\t authentication_token: new_user.authentication_token\n\t\t }\n\t\t \n\t\t }.to_json\n\t\telse\n\t\t render status: 404, json: {\n\t\t \tstatus: 404,\n\t\t errors: new_user.errors\n\t\t }.to_json\n\t\tend\n\tend",
"def create\n @user = User.new(user_params)\n @user.gravatar_usage = true if request.format.json?\n respond_to do |format|\n if @user.save\n format.html { redirect_to root_url }\n format.json { render json:{message: 'Creacion exitosa', activate: edit_account_activation_url(@user.activation_token, email: @user.email)}, status: :ok, location: @user}\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.create(user_params) \n render json: user, status: :created\n end",
"def create\n logger.info \" -------- user/create : #{user_params}\"\n logger.info \" -------- phoneNumber : #{user_params[:phoneNumber]}\"\n @user = User.find_by_phoneNumber(user_params[:phoneNumber])\n\n unless @user.nil?\n # If user already exists then return conflict error.\n # If client registration id is different then\n # update it.\n if @user.clientRegistrationId != user_params[:clientRegistrationId]\n @user.update_column(:clientRegistrationId, user_params[:clientRegistrationId])\n end\n respond_to do |format|\n error_msg = { :error => \"User(#{user_params[:phoneNumber]}) is already registered with ETA\" }\n format.json { render json: error_msg, status: :conflict }\n end\n else \n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user }\n format.json { head :created } \n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user.as_json(only: [:email, :authentication_token]), status: :created\n else\n head(:unprocessable_entity)\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n=begin\n rezzcard_user_params = User.get_rezzcard_user_params(params[:user])\n user_params = User.get_compass_user_params(params[:user])\n user_params[\"username\"] = user_params[\"email\"]\n=end\n @users = User.new(user_params)\n if @users.save\n flash[:notice] = I18n.t('admin.users.new.success', :name => @users.email)\n redirect_to :action => :index\n else\n render :action => :new\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n profile = @user.profile\n user_hash = { user: { id: @user.id, origin: @user.origin, open_id: @user.open_id,\n auth_token: @user.auth_token, password: @user.password, nickname: profile.nickname, avatar: profile.avatar.url }}\n format.json { render json: user_hash, status: :created }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render :json => user, :status => :created\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n params[:users].each do |u|\n EventsUser.create!([{ user_id: u.to_i, event_id: @event.id }])\n EventMailer.send_event_email(@event, u).deliver\n end\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n if params[:user][:app] == \"instainvoice\"\n options = {:body => {:user => {\n :email => params[:user][:email], :password => params[:user][:password], \n :referrer => params[:user][:referrer], :source => \"InstaInvoice\"}\n }\n \n }\n resp = HTTParty.post(\"http://billing.breeasy.com/api/v1/users.json\", options)\n #raise resp.body.inspect\n retval = JSON.parse(resp.body)\n elsif params[:user][:app] == \"bfsb\"\n \n options = {:body => {:user => {:email => params[:user][:email], :password => params[:user][:password],\n :first_name => params[:user][:first_name], :last_name => params[:user][:last_name],\n :title => params[:user][:title],\n :username => params[:user][:username],:refferal_code => params[:user][:referral_code]}\n },\n :query => {:plan_id => params[:plan_id]}\n }\n resp = HTTParty.post(\"http://app.breeasy.com/api/v1/users.json\", options)\n retval = JSON.parse(resp.body)\n \n end\n # user = User.find 35\n \n respond_to do |format|\n format.json { render :json => retval } # note, no :location or :status options\n end\n end",
"def create_user(application_name, application_id)\n res = nil\n user_id = VaultDriver.generate_uid\n uri = URI(@url + \"auth/#{application_name}/map/user-id/#{user_id}\")\n req = Net::HTTP::Post.new(uri)\n req['X-Vault-Token'] = @token\n application_data = { 'value' => application_id }\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n req.body = application_data.to_json\n http.request(req)\n end\n [user_id, res.code.to_i]\n end",
"def create\n user = User.new(user_params)\n\n respond_to do |format|\n if user.save\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tputs user_params\n\t\tuser = User.new(user_params)\n\t\tif user.save\n\t\t\trender json: { user: user, status: :success }\n\t\telse\n\t\t\trender json: { status: :failure, errors: user.errors.full_messages.join('') }\n\t\tend\n\tend",
"def create\r\n \r\n pa = params.require(:user).permit(:email, :password, :password_confirmation, :phone_number,\r\n :admin, :content_provider_id,\r\n :subscribed_alert_mediaspot_offline, :subscribed_alert_sync_error,\r\n :sms_subscribed_alert_mediaspot_offline, :sms_subscribed_alert_sync_error)\r\n\r\n pa[:api_key] = genereate_api_key\r\n\r\n @user = User.new(pa)\r\n \r\n respond_to do |format|\r\n if @user.save\r\n\r\n content_providers = []\r\n\r\n (params[:user][:content_provider_ids] || []).each do |k|\r\n id = k.to_i\r\n if id > 0\r\n content_providers << ContentProvider.find(id)\r\n end\r\n end\r\n @user.content_providers = content_providers\r\n\r\n save_users_log(current_user.email, 'user_created', {\r\n user: @user,\r\n content_providers: content_providers.map{|cp| { id: cp[:id], name: cp[:name] }}\r\n }.to_json)\r\n\r\n format.html { redirect_to @user, notice: 'User was successfully created.' }\r\n else\r\n format.html { render :new }\r\n end\r\n end\r\n\r\n end",
"def signup\n\t\tbegin\n\t\t\t@new_user = false\n\t\t first = params[:first]\n\t\t \tlast = params[:last]\n\t\t \temail = params[:email]\n\t\t \tpassword = params[:password]\n\t\t \tapi_key = SecureRandom.hex\n\n\t\t \tuser = nil\n\t\t \te = User.where(\"email = ?\", email).first\n\t\t\tif e == nil\n\t\t\t\t@new_user = true\n\t\t\t\tputs \"User is new...saving\"\n\t\t\t\tuser = User.new(first: first, last: last, email: email, password: password, api_key: api_key)\n\t\t\telse\n\t\t\t\tp 'User already exists...updating'\n\t\t\t\tuser = e\n\t\t\t\tuser.first = first\n\t\t\t\tuser.last = last\n\t\t\t\tuser.email = email\n\t\t\t\tuser.password = password\n\t\t\tend\n\n\t\t\tuser.save(:validate => false)\n\t\t\tif !user.persisted?\n\t\t\t\tp 'Issue saving user...'\n\t\t\t\trender json: nil\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tmgr_role = Role.where(\"name = ?\", \"manager\").first\n\n\t\t\tcheck = nil\n\t\t\tlm_check = nil\n\n\t\t\tif !@new_user\n\t\t\t\tcheck = UserRole.where(\"user_id = ? and role_id = ?\", user.id, mgr_role.id).first\n\t\t\t\tlm_check = LeagueManager.where(\"user_id = ?\", user.id).first\n\t\t\tend\n\n\t\t\tif check == nil\n\t\t\t\tp 'Creating manager user role'\n\t\t\t\tUserRole.create!(user_id: user[:id], role_id: mgr_role[:id])\n\t\t\telse\n\t\t\t\tp 'Manager role is existing...'\n\t\t\tend\n\n\t\t\tif lm_check == nil\n\t\t\t\tp 'Creating League Manager record'\n\t\t\t\tlm = LeagueManager.create(user_id: user[:id])\n\t\t\telse\n\t\t\t\tp 'League Manager is existing...'\n\t\t\tend\n\n\t\t\tif @new_user\n\t\t\t\t@email = email\n\t\t\t\t@first = first\n\t\t\t\t@api_key = api_key\n\t\t\t\t@email_content = 'confirm_email_mailer/confirm_email'\n\n\t\t\t \t@confirm_email_link = ENV['Admin_Domain'] + \"/#/pages/confirm_email?key=#{@api_key}\"\n\t\t\t\t \n\t\t\t\tclient = SendGrid::Client.new(api_key: ENV['SENDGRID'])\n\n\t\t\t\tmail = SendGrid::Mail.new do |m|\n\t\t\t\t\tm.to = @email\n\t\t\t\t\tm.from = 'support@ez4mysports.com'\n\t\t\t\t\tm.subject = 'Confirm your email address for EZ Sports'\n\t\t\t\t\tm.html = render_to_string(@email_content, :layout => false)\n\t\t\t\tend\n\n\t\t\t\tif send_email?\n\t\t\t\t\tp 'SENDING CONFIRM EMAIL'\n\t\t\t\t\tres = client.send(mail)\n\t\t\t\t\tputs res.code\n\t\t\t\t\tputs res.body\n\t\t\t\tend\n\t\t\tend\n\n\t\t\trender json: user\n\t\trescue => e\n\t\t\tHandleError(e)\n\t\t\trender json: nil\n\t\tend\n\tend",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\trender json: @user, status: :created, location: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def user_creation_for_guest_user(user)\n response = HTTParty.post(\"#{Rails.application.secrets.mapp_integration[:api_endpoint]}\"+\"/user/create\", headers: headers, query: user_creation_api_query(user), body: user_creation_api_body(user))\n end",
"def create_non_admin_user_authenticate\n post '/users', 'username' => 'testuser', 'password' => 'testpassword', 'email_address' => 'test@toto.com'\n id_user = last_response.json_body['id']\n digest_authorize 'testuser', 'testpassword'\n id_user\nend",
"def create\n @user = User.where(:email => params[:user][:email]).first\n\n if !@user.nil?\n \trender :json => {:success => false, :message => \"User already registered\"}, :status => 401\n else\n \tbegin\n\t\t @user = User.new(params[:user])\n @user.password = Devise.friendly_token[0,20]\n\t\t if @user.save\n\t\t @api_key = ApiKey.find_or_create_token_for(@user)\n\t\t render :json => {:success => true, :message => \"Registration successful\",:access_key => @api_key.access_token, :user => @user}, :status => 200\n\t\t else\n\t\t \trender :json => {:success => false, :message => \"Error while creating user\"}, :status => :not_acceptable\n\t\t end\n\t\t rescue Exception => e\n p e\n\t \tp e.backtrace\n\t render :json => {:success => false, :message => e.backtrace}, :status => :not_acceptable\n\t end\n\t end\n end",
"def sign_up\n\t\tif params[:uuid].present?\n\t\t\t@existing_member = Com::Nbos::User.where(uuid: params[:uuid])\n\t\t\tif @existing_member.present?\n\t\t\t\trender :json => @existing_member.first\n\t\t\telse\n\t\t\t\t@member = build_user(params)\n\t\t\t\tif @member && @member.save\n\t\t\t\t\trender :json => @member\n\t\t\t\telse\n\t\t\t\t\trender :json => {status: 500, message: @member.errors.messages}, status: 500\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender :json => {status: 400, message: \"Bad Request\"}, status: 400\n\t\tend\t\n\tend",
"def register\n usr=params[:user]\n pass=encryptor(usr[:password])\n confPass=encryptor(usr[:password_confirmation])\n #puts(pass)\n #puts(usr[:password])\n @key_name_prefix=\"grupo_\"\n options = {\n :body =>{\n \"firstName\": usr[:firstName],\n \"lastName\": usr[:lastName],\n \"email\": usr[:email],\n \"password\": pass,\n \"password_confirmation\": confPass\n }.to_json,\n :headers => {'Content-Type'=> 'application/json'\n }\n }\n #puts(options)\n resultsLDAP = HTTParty.post(\"http://192.168.99.104:4001/user/resources/ldapcruds\", options)\n if resultsLDAP.code == 201\n # options = {\n # :body => params.to_json,\n # :headers => {\n # 'Content-Type' => 'application/json'\n # }\n # }\n options = {\n :body =>{ \"user\":{\n \"firstName\": usr[:firstName],\n \"lastName\": usr[:lastName],\n \"email\": usr[:email],\n \"password\": pass,\n \"password_confirmation\": confPass\n }\n }.to_json,\n :headers => {'Content-Type'=> 'application/json'\n }\n }\n #puts(options)\n results = HTTParty.post(\"http://192.168.99.101:4051/users\", options)\n if results.code == 201\n user = results.parsed_response\n aux = params[:user]\n options = {\n :body =>{ \"notification_key\": \"\",\n \"user_id\": user\n }.to_json,\n :headers => {'Content-Type'=> 'application/json'\n }\n }\n results3 = HTTParty.post(\"http://192.168.99.101:4051/group_keys\".to_s,options)\n if results3.code == 201\n head 201\n else\n render json: results3.parsed_response, status: results3.code\n end\n else\n render json: results.parsed_response, status: results.code\n end\n elsif resultsLDAP.code == 400\n render json: {\"email\": [\"has already been taken\"]}.to_json, status: 422\n else\n renderError(\"Not Avalible\", 503, \"OpenLDAP server conection failed\")\n end\n end",
"def register_api\n begin\n email = register_api_params[:email].downcase\n @user = User.find_by_email(email)\n if @user.blank?\n @user = User.create(:email => email, :username => register_api_params[:username], :password => register_api_params[:password], :device_token => register_api_params[:device_token], :type => register_api_params[:type])\n render :json => @user\n else\n render :json => @user\n end\n rescue Exception => e\n error \"Please provide all required fields\"\n end\n end",
"def mf_api_user_create\n\n # Look for\n current_users = User.where(email: params[:email])\n\n unless current_users.empty?\n response = {\n success: false,\n message: 'User with email already exists'\n }\n\n render json: response and return\n end\n\n # Generate a password for user\n seed = \"--#{rand(10000000)}--#{Time.now}--#{rand(10000000)}\"\n secure_password = Digest::SHA1.hexdigest(seed)[0,8]\n\n user = User.new\n\n user.clientid = params[:client_id]\n user.email = params[:email]\n user.password = secure_password\n user.first_name = params[:first_name]\n user.last_name = params[:last_name]\n\n user.save\n\n # Update Infusionsoft Contact ------THIS LINE OF CODE IS WHERE IT FUCKS UP\n Infusionsoft.contact_update(params[:client_id], {:Password => secure_password})\n\n # Return Success Response\n response = {\n success: true,\n user_id: user.id,\n password: user.password,\n message: 'User Created'\n }\n\n render json: response\n\n\n end"
] |
[
"0.6259141",
"0.62283283",
"0.6210158",
"0.61411136",
"0.6134746",
"0.6126794",
"0.61217546",
"0.6099993",
"0.60931695",
"0.60412914",
"0.60357714",
"0.6026509",
"0.6025068",
"0.600273",
"0.5993673",
"0.5958619",
"0.5947786",
"0.59270746",
"0.5915842",
"0.5915638",
"0.59153664",
"0.5891763",
"0.5882005",
"0.5878665",
"0.5874858",
"0.586846",
"0.585979",
"0.5853578",
"0.5849685",
"0.5827956",
"0.5826008",
"0.5820029",
"0.58171827",
"0.58017236",
"0.579795",
"0.5793012",
"0.5790471",
"0.5789872",
"0.57867265",
"0.57831156",
"0.5772452",
"0.5772452",
"0.57713246",
"0.5766172",
"0.5761643",
"0.57446516",
"0.5741524",
"0.57396585",
"0.5737014",
"0.5734615",
"0.5734615",
"0.5734615",
"0.57338166",
"0.57331175",
"0.5731012",
"0.5731012",
"0.57277626",
"0.57186675",
"0.57160354",
"0.57142097",
"0.57140446",
"0.5713242",
"0.5712117",
"0.57104",
"0.5698179",
"0.56948596",
"0.56879586",
"0.56845355",
"0.56836843",
"0.5682823",
"0.5678836",
"0.56781906",
"0.5677277",
"0.5672054",
"0.5662885",
"0.5659254",
"0.56590474",
"0.5657237",
"0.56539726",
"0.5653601",
"0.5651416",
"0.5648708",
"0.5646923",
"0.5644082",
"0.5638417",
"0.5634298",
"0.56338733",
"0.56329954",
"0.56328416",
"0.56320846",
"0.56300545",
"0.5629532",
"0.5627653",
"0.56221175",
"0.561902",
"0.5606666",
"0.5602555",
"0.5602122",
"0.5596226",
"0.5595181"
] |
0.6727144
|
0
|
PUT /euclid_users/1 PUT /euclid_users/1.json
|
def update
@euclid_user = EuclidUser.find(params[:id])
respond_to do |format|
if @euclid_user.update_attributes(params[:euclid_user])
format.html { redirect_to @euclid_user, notice: 'Euclid user was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @euclid_user.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end",
"def put user_id, options={}, headers={}\n @connection.put \"users/#{user_id}.json\", options, headers\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end",
"def update\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.update(jam_circle_params)\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :ok, location: @jam_circle }\n else\n format.html { render :edit }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end",
"def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end",
"def update_user(options)\n patch(\"/user\", options, 3)\n end",
"def update_user\n end",
"def update!\n unless id\n raise \"user can not be updated before it is created.\"\n end\n hash = \"W10=\"\n\n payload = {\n \"id\" => id,\n \"email\" => @email_address,\n \"time_zone\" => @time_zone,\n \"country\" => @country,\n \"preferred_language\" => @language,\n \"receive_campaign_emails\" => \"true\",\n \"hash\" => hash,\n \"username\" => @email_address,\n \"last_login_at\" => get_last_login_at!,\n \"password\" => @password,\n \"password_confirmation\" => @confirm_password,\n \"user\" => {\n \"email\" => @email_address,\n \"password\" => @password,\n \"password_confirmation\" => @confirm_password,\n \"time_zone\" => @time_zone,\n \"receive_campaign_emails\" => \"true\",\n \"country\" => @country,\n \"preferred_language\" => @language\n }\n }\n\n response = authenticated_request(:put, \"api/client/users/#{id}\", payload: payload)\n response[:status]\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end",
"def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end",
"def update\n begin\n user = User.find(params[:user_id])\n if user.update(user_params)\n render json: { users: user }, status: :ok\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n rescue => e\n render json: { errors: e.message }, status: 404\n end\n end",
"def update_user(user, options = {})\n put \"/users/#{user}\", options\n end",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update\n user = find_user\n user.update!(user_params)\n render json: user\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end",
"def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update user_params(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\n end",
"def update\n @user.update(user_params_update)\n json_response(@user)\n end",
"def create\n @euclid_user = EuclidUser.new(params[:euclid_user])\n @euclid_user.proximity = \"distant\";\n\n respond_to do |format|\n if @euclid_user.save\n format.html { redirect_to @euclid_user, notice: 'Euclid user was successfully created.' }\n format.json { render json: @euclid_user, status: :created, location: @euclid_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @euclid_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end",
"def update\n respond_to do |format|\n if @user.update(form_params)\n format.json { render json: { users: @user }, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def update\n if @user.update(user_params)\n render json: @user, status: 200\n else\n render json: @user.errors, status: 422\n end\n end",
"def update\n\t\tif @user.update(user_params)\n\t\t\trender json: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params[:user]))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = current_api_user\n unless @user.update(user_params)\n render json: { error: @user.errors.full_messages.to_sentence }, status: :not_found\n end\n end",
"def update_user\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status :unprocessable_entity\n end\n end",
"def update\n updated_user = user_params\n\n if params[:user][:do_not_email] == '1'\n updated_user[:marketing] = '0'\n updated_user[:articles] = '0'\n updated_user[:digest] = '0'\n end\n\n user = Token.consume(params[:user][:nonce])\n\n if user == nil or user.id.to_s != params[:id] or params[:user][:url_email] != user.email\n flash[:alert] = 'Access denied!'\n redirect_to action: 'edit'\n return\n elsif user.email != params[:user][:email]\n email_already_exists = email_already_exists?(params[:user][:email])\n if email_already_exists\n redirect_to action: 'edit'\n return\n end\n else\n respond_to do |format|\n if @user.update(updated_user)\n format.html { redirect_to action: 'index' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update_user(id, accountId, model) path = \"/api/v2/accounts/#{accountId}/users/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end",
"def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update \n @current_user.update(user_params)\n render json: @current_user\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if user.update(user_params)\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n render json:@user\n else\n render json: { error: {code: 404, message: 'Invalid user' }}, status: :not_found\n end\n end",
"def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end",
"def update\n respond_to do |format|\n if @cas_user.update(cas_user_params)\n format.html { redirect_to @cas_user, notice: 'Cas user was successfully updated.' }\n format.json { render :show, status: :ok, location: @cas_user }\n else\n format.html { render :edit }\n format.json { render json: @cas_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user(uid, params={})\n begin\n RestClient.post construct_url(\"user/#{uid}\"), params\n true\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end",
"def update\n @user = selected_user\n if @user.update(users_params)\n render 'api/users/show'\n else\n render json: @user.errors.full_messages, status: 422\n end\n end",
"def update\n @user = current_user\n if @user.update(update_user_params)\n render 'api/v1/users/show'\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @user.update(name: user_params[:name], email: user_params[:email], end_date: user_params[:end_date])\n user_params[:cycle_ids].reject(&:empty?).each_with_index do |id, index|\n role_id = user_params[:role_ids].reject(&:empty?)\n company_id = user_params[:company_ids].reject(&:empty?)\n CoUserRoleCycle.where( user_id: @user.id).destroy_all\n CoUserRoleCycle.create(user_id: @user.id, cycle_id: id, role_id: role_id[index], company_id: company_id[index])\n end\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(options: {})\n\t\t\tuser = User.perform_request User.api_url(\"users/#{id}\"), :put, options, true\n\n\t\t\tif user\n\t\t\t\toptions.each do |key, value|\n\t\t\t\t\tself.send(\"#{key}=\", user['data'][\"#{key}\"])\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend",
"def user_update_me(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserApi#user_update_me ... opts: #{opts}\"\n end\n\n # resource path\n path = \"/user\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n form_params[\"firstname\"] = opts[:'firstname'] if opts[:'firstname']\n form_params[\"lastname\"] = opts[:'lastname'] if opts[:'lastname']\n form_params[\"oldPassword\"] = opts[:'old_password'] if opts[:'old_password']\n form_params[\"newPassword\"] = opts[:'new_password'] if opts[:'new_password']\n form_params[\"newPasswordConfirm\"] = opts[:'new_password_confirm'] if opts[:'new_password_confirm']\n form_params[\"country\"] = opts[:'country'] if opts[:'country']\n form_params[\"pgpPubKey\"] = opts[:'pgp_pub_key'] if opts[:'pgp_pub_key']\n\n # http body (model)\n post_body = nil\n\n\n auth_names = []\n result = @api_client.call_api(:PUT, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'User')\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserApi#user_update_me. Result: #{result.inspect}\"\n end\n return result\n end",
"def update\n @user.annual = @user.user_id.slice(1..4)\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'ユーザーの更新が完了しました。' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[\"user\"].each do |key, value| \n value.strip!\n if value == \"\"\n params[\"user\"].delete(key)\n end\n end\n \n params[\"user\"][\"email\"].downcase!\n \n @prev_user_info = User.find_by_id(params[\"user\"][\"id\"])\n existing_user = User.find_by_id(params[\"user\"][\"id\"])\n \n if !params[\"user\"][\"password_hash\"].blank?\n existing_user.password = params[\"user\"][\"password_hash\"]\n end\n\n if existing_user.update_attributes(params[\"user\"])\n @object = existing_user\n \n render \"user_success\"\n\n else\n @error_messages = existing_user.errors.to_a\n @user = User.new\n @new_item = User.find_by_id(params[\"id\"])\n\n render \"edit\"\n end\n end",
"def test_user_update\n new_data = {\n 'OrgDefinedId' => 'ruby-test',\n 'FirstName' => 'Test-User',\n 'MiddleName' => 'changed',\n 'LastName' => 'Test',\n 'ExternalEmail' => nil, # Predefines user data, in the case that\n 'UserName' => 'test-ruby-user1234', # there is are variables left out in the JSON\n 'Activation' => {\n 'IsActive' => true\n }\n }\n user_id = get_user_by_username(new_data['UserName'])['UserId']\n update_user_data(user_id, new_data)\n end",
"def update_user(data, options = {})\n GoodData::Domain.update_user(data, { client: client }.merge(options))\n end",
"def update\n user = User.find(params[:id])\n if user.update(params_user)\n render json: user, status: 200\n else\n render json: user.errors, status: 422\n end\n\n end",
"def update\n user_info = User.find(params[:id])\n if !user_info.points\n @user[:points] = 100\n end\n if !user_info.image\n @user[:image] = 'https://graph.facebook.com/'+user_info.uid.to_s+'/picture?width=360&height=210'\n end\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @v1_user.update(v1_user_params)\n format.html { redirect_to @v1_user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @v1_user }\n else\n format.html { render :edit }\n format.json { render json: @v1_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n authorize @user\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: user\n else\n render json: user.errors.full_messages\n end\n end",
"def update\n user = User.find(params[:id])\n render json: { status: 200, msg: 'User details have been updated.' } if user.update(user_params)\n end",
"def update\n respond_to do |format|\n if @v2_user.update(v2_user_params)\n format.html { redirect_to @v2_user, notice: \"V2 user was successfully updated.\" }\n format.json { render :show, status: :ok, location: @v2_user }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @v2_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif @user.update(users_params)\n \t\tjson_response(@user, \"User Update Successfully.\")\n \telse\n \t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n \tend\n\tend",
"def update(id, params = {})\n request(:put, \"/users/#{id}\", body: params)\n end",
"def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end",
"def update\n UserComposite.new( user_params.merge(id: params[:id]) ).update!\n render json: StatusSerializer.new(:accepted), status: :accepted\n rescue ActiveRecord::RecordInvalid => ex\n render json: UserSerializer.new( ex.record ), status: :unprocessable_entity\n end",
"def update\n @ecnuser = Ecnuser.find(params[:id])\n\n respond_to do |format|\n if @ecnuser.update_attributes(params[:ecnuser])\n format.html { redirect_to(@ecnuser, :notice => 'Ecnuser was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ecnuser.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @api_user = ApiUser.find(params[:id])\n\n if @api_user.update(api_user_params)\n head :no_content\n else\n render json: @api_user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @club = Club.find(params[:id])\n\n params.each do |key, value|\n if (key.to_s[/adduser.*/])\n #if param[key].blank?\n # @object.errors.add_to_base(\"All new user fields are required.\")\n #end\n #debugger\n @user = User.new\n #clean_up_passwords @user\n @user.update_attribute(:email,params[key])\n @user.update_attribute(:club_id,params[:id])\n @user.save\n #@user.send_confirmation_instructions\n end\n end\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @users = User.all.order(nombre1: :asc)\n if params[:coference][:user_ids]\n params[:coference][:user_ids] = params[:coference][:user_ids].map{|k, v| k}\n else\n params[:coference][:user_ids] = []\n end\n\n respond_to do |format|\n if @coference.update(coference_params)\n format.html { redirect_to @coference, notice: 'La actividad se actualizo con exito.' }\n format.json { render :show, status: :ok, location: @coference }\n else\n format.html { render :edit }\n format.json { render json: @coference.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n @user = User.find(params[:id]) \n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User #{@user.name} was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to ({action:'index'}), notice: 'ユーザー情報を編集しました' }\n format.json { render :show, status: :ok, location: @user }\n else\n set_superiors\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update(user_params)\n render :show, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render :show, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render :show, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n begin\n if request.content_type == \"application/json\" # Validamos el formato\n if @user.update(user_params)\n render json: @user\n else\n render status: :bad_request\n end\n else\n render status: :bad_request\n end\n rescue => exception\n # En caso de cualquier error que pueda ocurrir de formato u otro no capturado, devolveremos un status 400\n render status: :bad_request\n end\n \n end",
"def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: {\n status: 'OK',\n msg: 'User details have been updated.',\n error: 'nil'\n }, status: :accepted\n else\n not_good(406)\n end\n end",
"def update\n load_user\n build_user\n respond_to do |format|\n if user.save\n format.html { redirect_to user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @ser }\n else\n format.html { render :edit }\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: @employee_user.errors unless @employee_user.update(employee_user_params)\n end",
"def update_profile\n @ecnuser = Ecnuser.find(@user.id)\n params[:ecnuser][:username] = @ecnuser.username\n params[:ecnuser][:email] = @ecnuser.email\n \n respond_to do |format|\n if @ecnuser.update_attributes(params[:ecnuser])\n format.html { redirect_to( root_path, :notice => 'Ecnuser was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit_profile\" }\n format.xml { render :xml => @ecnuser.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(current_identity.user_id)\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n #head :no_content\n render json: @user, status: :accepted, location: @user #sera? status accepted? \n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\tif @user.update(user_params)\n\t\t\tformat.html { redirect_to root_path, notice: 'Информация о пользователе успешно обновлена.' }\n\t\t\tformat.json { render :show, status: :ok, location: @user }\n\t\telse\n\t\t\tformat.html { render :edit }\n\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\tend\n\t\tend\n\tend"
] |
[
"0.67932063",
"0.6774995",
"0.6708661",
"0.6584418",
"0.65644723",
"0.6553645",
"0.6550216",
"0.6545514",
"0.6471925",
"0.646046",
"0.6438865",
"0.64369965",
"0.64322716",
"0.6414681",
"0.6414681",
"0.6402894",
"0.64004993",
"0.63678604",
"0.63527614",
"0.63241565",
"0.63241565",
"0.6323465",
"0.63111144",
"0.62989724",
"0.6293814",
"0.629082",
"0.62890965",
"0.62817633",
"0.6276032",
"0.62690103",
"0.62663865",
"0.6265792",
"0.6260928",
"0.62577534",
"0.625578",
"0.6249377",
"0.62334824",
"0.623181",
"0.6214284",
"0.62111044",
"0.621108",
"0.6202868",
"0.6195205",
"0.6176115",
"0.6171678",
"0.6171678",
"0.61716336",
"0.61705434",
"0.6165182",
"0.6165182",
"0.6161989",
"0.61610544",
"0.61572087",
"0.61559004",
"0.61559004",
"0.613033",
"0.6124228",
"0.6101824",
"0.60960907",
"0.608655",
"0.6077007",
"0.60702366",
"0.6064779",
"0.6062671",
"0.60625714",
"0.60576636",
"0.6056517",
"0.60397375",
"0.6039735",
"0.6038398",
"0.6030482",
"0.60296756",
"0.6027858",
"0.60240597",
"0.60233146",
"0.60165703",
"0.60065746",
"0.6004986",
"0.60042936",
"0.59983146",
"0.59868133",
"0.598568",
"0.5984959",
"0.5979111",
"0.5971134",
"0.59702635",
"0.59679735",
"0.5966854",
"0.5957365",
"0.5957365",
"0.5957365",
"0.5957136",
"0.59560543",
"0.595435",
"0.5950948",
"0.59488094",
"0.5940765",
"0.5933393",
"0.59322983",
"0.59308577"
] |
0.71763444
|
0
|
DELETE /euclid_users/1 DELETE /euclid_users/1.json
|
def destroy
@euclid_user = EuclidUser.find(params[:id])
@euclid_user.destroy
respond_to do |format|
format.html { redirect_to euclid_users_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def user_management_delete_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"id\" => id,\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.delete query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 404\n raise APIException.new \"Not found\", 404, response.raw_body\n elsif response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end",
"def user_delete(user_id)\n\t\tdelete_call = Curl::Easy.http_delete(\"#{@ip_address}:#{@port_2}/v2.0/users/#{user_id}\"\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['userId'] = user_id\n\t\tend\n\t\n\tend",
"def remove_user\n query_api '/rest/user', nil, 'DELETE'\n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def destroy\n HerosUsers.destroy_all(:user_id => @user.id)\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def destroy\n @api_user.destroy\n\n head :no_content\n end",
"def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end",
"def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete_user(uid)\n begin\n RestClient.delete construct_url(\"user/#{uid}\")\n true\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end \n end",
"def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete user_id, options={}, headers={}\n @connection.delete \"users/#{user_id}.json\", options, headers\n end",
"def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = current_org.users.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @user.destroy\n format.json { head :no_content }\n end",
"def delete(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'DELETE',\n path: path,\n headers: headers,\n params: params,\n )\n end",
"def destroy\n @user = User.find(params[:user_uuid])\n @user.destroy\n head :ok\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @user_id = UserId.find(params[:id])\n @user_id.destroy\n\n respond_to do |format|\n format.html { redirect_to user_ids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to dm_core.admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end",
"def destroy\n @user = User.find(params[:id])\n User.cascade_delete(@user)\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def delete_user\n client.delete(user)\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def call(id)\n client.delete(\"/api/rest/v1/users/#{id}.json\")\n true\n end",
"def destroy\n @user = User.find(params[:id])\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_path, notice: 'The user and all associated events were successfully deleted.'}\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @client_user.destroy\n respond_to do |format|\n format.html { redirect_to client_users_url, notice: 'Client user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end"
] |
[
"0.72144127",
"0.7078144",
"0.7068458",
"0.70267",
"0.7009003",
"0.69466496",
"0.6919501",
"0.6901847",
"0.6868615",
"0.68578565",
"0.6841119",
"0.6840021",
"0.6832048",
"0.68235826",
"0.6821509",
"0.6820895",
"0.6800377",
"0.6786589",
"0.6784441",
"0.6784441",
"0.6781281",
"0.67754686",
"0.6771418",
"0.6760214",
"0.67468655",
"0.6735809",
"0.67301315",
"0.6702865",
"0.66987985",
"0.66987437",
"0.66844934",
"0.66828316",
"0.66733027",
"0.66655266",
"0.666543",
"0.66651547",
"0.66651237",
"0.66651237",
"0.66648346",
"0.6652678",
"0.66511595",
"0.6643253",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.664093",
"0.6640098",
"0.6636773",
"0.66339004",
"0.66327333",
"0.66314745",
"0.6627268",
"0.6627119",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483",
"0.6625483"
] |
0.76037097
|
0
|
GET /quandaries GET /quandaries.json
|
def index
@quandaries = Quandary.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @enquiries = @product.enquiries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enquiries }\n end\n end",
"def index\n @qandas = Qanda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qandas }\n end\n end",
"def index\n @qus = Qu.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @qus }\n end\n end",
"def show\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiniela }\n end\n end",
"def index\n @q_resources = QResource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @q_resources }\n end\n end",
"def index\n @quizzes = Quiz.all \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quizzes }\n end\n end",
"def show\n @qurriculum = Qurriculum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qurriculum }\n end\n end",
"def set_quandary\n @quandary = Quandary.find(params[:id])\n end",
"def show\n @quize = Quize.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quize }\n end\n end",
"def index\n @quizes = Quize.all\n end",
"def show\n @quartet = Quartet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quartet }\n end\n end",
"def index\n @qors = Qor.all\n end",
"def index\n @quxes = Qux.all\n end",
"def index\n @qualifications = Qualification.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qualifications }\n end\n end",
"def index\n @quata = Quatum.all\n end",
"def show\n @qu = Qu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @qu }\n end\n end",
"def show\n @qu = Qu.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @qu }\n end\n end",
"def index\n @quartets = Quartet.all\n end",
"def index\n @quantities = Quantity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quantities }\n end\n end",
"def destroy\n @quandary.destroy\n respond_to do |format|\n format.html { redirect_to quandaries_url, notice: 'Quandary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def getQuartier\r\n \tarrondissement = params[:id]\r\n \trender json: Quartier.where(arrondissement_id: arrondissement)\r\n end",
"def show\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quarter }\n end\n end",
"def create\n @quandary= current_user.quandaries.build(quandary_params)\n\n respond_to do |format|\n if @quandary.save\n format.html { redirect_to @quandary, notice: 'Quandary was successfully created.' }\n format.json { render :show, status: :created, location: @quandary }\n else\n format.html { render :new }\n format.json { render json: @quandary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n quizzes = Quiz.all\n render json: quizzes, except: [:updated_at, :created_at]\n end",
"def show\n @quartier = Quartier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quartier }\n end\n end",
"def instructor_index\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\trender json: quizzes.as_json(:only => [:id, :name, :created_at, :no_of_MCQ, :no_of_rearrangeQ]), status: 200\n\t\tend",
"def index\n @quants = Quant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quants }\n end\n end",
"def query\n\n JSON.parse(Net::HTTP.get(self.build_uri))\n\n end",
"def index\n faqs = Faq.all\n json_response(faqs)\n end",
"def index\n @quartos = Quarto.all\n end",
"def index\n @qas = Qa.all\n end",
"def index\n @books = []\n if (params[:q])\n @books = Book.where(params[:q])\n end\n render :json => @books\n end",
"def index\n\t#params[:quest_id]\n #@qrcodes = Qrcode.find_all_by_userid(current_user.id)\n #@qrcodes= Qrcode.all\n@qrcodes = Qrcode.find_all_by_quest_id(params[:quest_id])\n@quest = Quest.find(params[:quest_id])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qrcodes }\n end\n end",
"def index\n @faqs = Faq.all\n\n render json: @faqs\n end",
"def index\n @quadernis = Quaderni.all\n end",
"def index\n @questionaries = Questionary.all\n end",
"def show\n @aquarium = Aquarium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aquarium }\n end\n end",
"def index\n @qrs = Qr.all\n end",
"def index\n puts params[:cycle_id];\n\n render json: Week.where({cycle_id: params[:cycle_id]}).as_json(\n include: [\n stocks: {\n :include => {\n orders: {\n include: [prossumer: {except: [:encrypted_password, :salt, :confirm_hash]}]\n },\n product: {\n include: [prossumer: {except: [:encrypted_password, :salt, :confirm_hash]}]\n }\n }\n }\n ])\n end",
"def show\n @qanda = Qanda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qanda }\n end\n end",
"def index\n @bill_quorums = BillQuorum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bill_quorums }\n end\n end",
"def index\n @equities = Equity.all\n end",
"def index\n @equities = Equity.all\n end",
"def show\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quest }\n end\n end",
"def scubooks\n sections = Section.all\n render json: sections\n end",
"def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend",
"def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qanda }\n end\n end",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end",
"def index\n @quclity_checks = QuclityCheck.all\n end",
"def show\n @queencell = Queencell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @queencell }\n end\n end",
"def index\n if params[:q]\n url = \"http://api.worldweatheronline.com/premium/v1/tz.ashx?q=#{params[:q]}&format=json&key=2c46659bd90a41a0bcf132257162410\"\n @json = ActiveSupport::JSON.decode(open(url).read)\n else\n end\n end",
"def index\n @requisitions = Requisition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requisitions }\n end\n end",
"def index\n @categoria_quarto = CategoriaQuarto.all\n end",
"def index\n @rnaseqs = Rnaseq.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rnaseqs }\n end\n end",
"def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end",
"def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end",
"def index\n @guys = Guy.all\n respond_to do |format|\n format.json { render json: @guys }\n end\n end",
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end",
"def show\n @quay = Quay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quay }\n end\n end",
"def index\n @questions = @subsection.questions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @qishis = Qishi.all\n end",
"def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end",
"def index\n chapters = @project.chapters.all\n render json: { chapters: chapters }\n end",
"def show\n @qa = Qa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qa }\n end\n end",
"def index\n @questionnaires = @instance.questionnaires\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questionnaires }\n end\n end",
"def index\n @curriculums = Curriculum.all\n respond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@curriculums) }\n\t\tend\n end",
"def index\n @specialties = Specialty.all\n\n render json: @specialties\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def index\n render json: Loan.all\n end",
"def quiz_get\r\n # allow receiving all parameters\r\n params.permit!\r\n\r\n # response format pre-defined\r\n result = {:str_uid => nil, :obj_quizprop => nil, :arr_items => nil }\r\n\r\n begin\r\n target_quiz = Mongodb::BankQuizQiz.find_by(_id: params[:str_rid])\r\n result[:str_uid] = params[:str_uid]\r\n result[:obj_quizprop] = target_quiz\r\n result[:arr_items] = target_quiz.quiz_detail\r\n rescue Exception => ex\r\n # do nothing for current \r\n end\r\n\r\n result_json = Common::Response.exchange_record_id(result.to_json)\r\n render :text=>Common::Response.format_response_json(result_json,Common::Response.get_callback_type(params))\r\n end",
"def index\n @quests = Quest.all\n end",
"def index\n @quests = Quest.all\n end",
"def index\n @phrasebooks = Phrasebook.all\n\n render json: @phrasebooks\n end",
"def index\n if params[:q] && params[:q][:id].present?\n category_id = params[:q][:id]\n root_category_id = QuotationCategory.find(category_id).root_id\n @q = case root_category_id\n when 1\n Quotation.ransack(quotation_category0_id_eq: category_id)\n when 2\n Quotation.ransack(quotation_category1_id_eq: category_id)\n when 3\n Quotation.ransack(quotation_category2_id_eq: category_id)\n end\n @quotations = @q.result.page(params[:page] || 1).per(params[:per_page] || 20).order(id: \"DESC\")\n else\n @q = Quotation.ransack(quotation_category0_id_eq: 4)\n @quotations = @q.result.page(params[:page] || 1).per(params[:per_page] || 20).order(id: \"DESC\")\n end\n end",
"def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end",
"def index\n @quizzes = Quiz.all.where(lesson_id: current_lesson.id)\n end",
"def show\n @quip = Quip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quip }\n end\n end",
"def index\n @qs = Q.all\n end",
"def show\n @q_resource = QResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @q_resource }\n end\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def index\n @quotation_units = QuotationUnit.all\n end",
"def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end",
"def show\n @qualification = Qualification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qualification }\n end\n end",
"def index\n \n @qa_clients = QaClient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qa_clients }\n end\n end",
"def index\n @purchases = Purchase.all.order(purchase_date: :desc).order(created_at: :desc).paginate(:page => params[:page], per_page: 10)\n\n render json: {purchases: @purchases, total_pages: @purchases.total_pages, current_page: @purchases.current_page}\n end",
"def index\n @assessment_end_chapter_quizzes = AssessmentEndChapterQuiz.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_end_chapter_quizzes }\n end\n end",
"def do_query(params) \n link = @api_url + \"/brief/json/\" + params\n return MultiJson.load( open(link).read )\n end",
"def index\n @pizzas = Pizza.all\n render json: @pizzas\n end",
"def index\n @references = Reference.all\n\n render json: @references\n end",
"def index\n if current_user.admin?\n @q = Quiz.ransack(params[:q])\n @quizzes = @q.result.includes(:questions, :section).paginate(page: params[:page])\n else\n redirect_to root_path\n flash[:notice] = \"Whoops! You're not supposed to be there!\"\n end\n end"
] |
[
"0.61279315",
"0.6097457",
"0.6088066",
"0.6036146",
"0.6034176",
"0.60301036",
"0.60092074",
"0.59902686",
"0.5989661",
"0.5957071",
"0.59337425",
"0.5905685",
"0.59052444",
"0.59038985",
"0.590354",
"0.5884594",
"0.5883558",
"0.5877946",
"0.585553",
"0.5842793",
"0.5827917",
"0.582756",
"0.57855666",
"0.57812214",
"0.57777727",
"0.57774687",
"0.5759028",
"0.57568",
"0.5746467",
"0.5739172",
"0.5730343",
"0.57059544",
"0.5701913",
"0.56822395",
"0.5672524",
"0.56538135",
"0.56294084",
"0.56091267",
"0.5599595",
"0.55948335",
"0.5583374",
"0.5579304",
"0.5579304",
"0.55728537",
"0.557184",
"0.556956",
"0.5564808",
"0.5563869",
"0.55620164",
"0.5561171",
"0.55457073",
"0.55416286",
"0.5538069",
"0.5533447",
"0.553134",
"0.55259484",
"0.5525456",
"0.552194",
"0.5518039",
"0.5513575",
"0.548911",
"0.5488488",
"0.54671633",
"0.5457925",
"0.54442835",
"0.54442835",
"0.54442835",
"0.54442835",
"0.54442835",
"0.543473",
"0.5425746",
"0.54246396",
"0.5423227",
"0.54190457",
"0.541871",
"0.5414357",
"0.54102445",
"0.54102445",
"0.54090077",
"0.5390935",
"0.5390556",
"0.5390556",
"0.53896827",
"0.53896147",
"0.5386676",
"0.53854287",
"0.5383897",
"0.53815234",
"0.5377775",
"0.53766537",
"0.5376054",
"0.5374939",
"0.537371",
"0.5371397",
"0.5361063",
"0.5359316",
"0.53588223",
"0.53562796",
"0.5353689",
"0.5351932"
] |
0.7351676
|
0
|
GET /quandaries/1 GET /quandaries/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @quandaries = Quandary.all\n end",
"def show\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiniela }\n end\n end",
"def show\n @qu = Qu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @qu }\n end\n end",
"def show\n @quize = Quize.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quize }\n end\n end",
"def show\n @qu = Qu.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @qu }\n end\n end",
"def show\n @qurriculum = Qurriculum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qurriculum }\n end\n end",
"def show\n @quartet = Quartet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quartet }\n end\n end",
"def show\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quarter }\n end\n end",
"def show\n @quartier = Quartier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quartier }\n end\n end",
"def getQuartier\r\n \tarrondissement = params[:id]\r\n \trender json: Quartier.where(arrondissement_id: arrondissement)\r\n end",
"def show\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quest }\n end\n end",
"def index\n @qus = Qu.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @qus }\n end\n end",
"def show\n @aquarium = Aquarium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aquarium }\n end\n end",
"def index\n @qandas = Qanda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qandas }\n end\n end",
"def query\n\n JSON.parse(Net::HTTP.get(self.build_uri))\n\n end",
"def show\n @qanda = Qanda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qanda }\n end\n end",
"def index\n @enquiries = @product.enquiries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enquiries }\n end\n end",
"def index\n @q_resources = QResource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @q_resources }\n end\n end",
"def set_quandary\n @quandary = Quandary.find(params[:id])\n end",
"def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end",
"def index\n @quizzes = Quiz.all \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quizzes }\n end\n end",
"def index\n @qualifications = Qualification.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qualifications }\n end\n end",
"def show\n @quip = Quip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quip }\n end\n end",
"def show\n @q_resource = QResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @q_resource }\n end\n end",
"def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end",
"def show\n @quay = Quay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quay }\n end\n end",
"def index\n @quantities = Quantity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quantities }\n end\n end",
"def show\n @qa = Qa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qa }\n end\n end",
"def show\n @qualification = Qualification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qualification }\n end\n end",
"def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend",
"def show\n @queencell = Queencell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @queencell }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qanda }\n end\n end",
"def index\n quizzes = Quiz.all\n render json: quizzes, except: [:updated_at, :created_at]\n end",
"def index\n @quartets = Quartet.all\n end",
"def show\n @quiz = Quiz.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiz }\n end\n end",
"def instructor_index\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\trender json: quizzes.as_json(:only => [:id, :name, :created_at, :no_of_MCQ, :no_of_rearrangeQ]), status: 200\n\t\tend",
"def index\n @quata = Quatum.all\n end",
"def show\n @squish = Squish.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squish }\n end\n end",
"def index\n\t#params[:quest_id]\n #@qrcodes = Qrcode.find_all_by_userid(current_user.id)\n #@qrcodes= Qrcode.all\n@qrcodes = Qrcode.find_all_by_quest_id(params[:quest_id])\n@quest = Quest.find(params[:quest_id])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qrcodes }\n end\n end",
"def show\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quantity }\n end\n end",
"def show\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quantity }\n end\n end",
"def show\n quote = Quote.find(params[:id])\n render json: quote\n end",
"def show\n @q_response = QResponse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @q_response }\n end\n end",
"def index\n @quants = Quant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quants }\n end\n end",
"def index\n @quizes = Quize.all\n end",
"def destroy\n @quandary.destroy\n respond_to do |format|\n format.html { redirect_to quandaries_url, notice: 'Quandary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def show\n @rnaseq = Rnaseq.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rnaseq }\n end\n end",
"def show\n @user_quest = UserQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_quest }\n end\n end",
"def new\n @quiniela = Quiniela.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quiniela }\n end\n end",
"def show\n @quetion = Quetion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quetion }\n end\n end",
"def get_thing(query_hash)\n query = {\"type\" => \"/type/edition\"}.merge(query_hash)\n response = open(@api_url + \"/things?query=\" + CGI.escape(query.to_json) ).read\n JSON.parse(response)\n end",
"def index\n @requisitions = Requisition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requisitions }\n end\n end",
"def show\n @purchase_requisition = PurchaseRequisition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @purchase_requisition }\n end\n end",
"def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end",
"def show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender json: question\n \tend",
"def show\n @squawk = Squawk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squawk }\n end\n end",
"def index\n @faqs = Faq.all\n\n render json: @faqs\n end",
"def new\n @quize = Quize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quize }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quotation }\n end\n end",
"def do_query(params) \n link = @api_url + \"/brief/json/\" + params\n return MultiJson.load( open(link).read )\n end",
"def show\n @qborentestimate = Qborentestimate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qborentestimate }\n end\n end",
"def show\n @fundamentals_history = @company.fundamentals_histories.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundamentals_history }\n end\n end",
"def index\n puts params[:cycle_id];\n\n render json: Week.where({cycle_id: params[:cycle_id]}).as_json(\n include: [\n stocks: {\n :include => {\n orders: {\n include: [prossumer: {except: [:encrypted_password, :salt, :confirm_hash]}]\n },\n product: {\n include: [prossumer: {except: [:encrypted_password, :salt, :confirm_hash]}]\n }\n }\n }\n ])\n end",
"def new\n @quartet = Quartet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quartet }\n end\n end",
"def new\n @quarter = Quarter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quarter }\n end\n end",
"def index\n @quxes = Qux.all\n end",
"def new\n @qu = Qu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @qu }\n end\n end",
"def new\n @qu = Qu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @qu }\n end\n end",
"def get(path, query={})\n request_json :get, path, query\n end",
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def index\n @specialties = Specialty.all\n\n render json: @specialties\n end",
"def quiz_get\r\n # allow receiving all parameters\r\n params.permit!\r\n\r\n # response format pre-defined\r\n result = {:str_uid => nil, :obj_quizprop => nil, :arr_items => nil }\r\n\r\n begin\r\n target_quiz = Mongodb::BankQuizQiz.find_by(_id: params[:str_rid])\r\n result[:str_uid] = params[:str_uid]\r\n result[:obj_quizprop] = target_quiz\r\n result[:arr_items] = target_quiz.quiz_detail\r\n rescue Exception => ex\r\n # do nothing for current \r\n end\r\n\r\n result_json = Common::Response.exchange_record_id(result.to_json)\r\n render :text=>Common::Response.format_response_json(result_json,Common::Response.get_callback_type(params))\r\n end",
"def show\n @quest_tree = QuestTree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quest_tree }\n end\n end",
"def create\n @quandary= current_user.quandaries.build(quandary_params)\n\n respond_to do |format|\n if @quandary.save\n format.html { redirect_to @quandary, notice: 'Quandary was successfully created.' }\n format.json { render :show, status: :created, location: @quandary }\n else\n format.html { render :new }\n format.json { render json: @quandary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def show\n @quiz=Quiz.find(params[:id])\n render json: @quiz.show_full_details\n end",
"def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def index\n faqs = Faq.all\n json_response(faqs)\n end",
"def show\n @jurisdiction = Jurisdiction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jurisdiction }\n end\n end",
"def show\n @qqcar = Qqcar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qqcar }\n end\n end",
"def index\n @qors = Qor.all\n end",
"def index\n @quadernis = Quaderni.all\n end",
"def show\n @joy = Joy.find(params[:id])\n render json: @joy\n end",
"def show\n @exercises = Exercise.where(\"chapter_id = ?\", params[:id]).order(:number)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chapter }\n end\n end",
"def index\n if params[:q]\n url = \"http://api.worldweatheronline.com/premium/v1/tz.ashx?q=#{params[:q]}&format=json&key=2c46659bd90a41a0bcf132257162410\"\n @json = ActiveSupport::JSON.decode(open(url).read)\n else\n end\n end",
"def show\n @quote = Quote.first\n render json: @quote\n end",
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def show\n @qa = Qa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :xml => @qa.to_json(:include => [:answer, :question]) }\n end\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def index\n @bill_quorums = BillQuorum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bill_quorums }\n end\n end",
"def show\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n @cartucho = Cartucho.find(params[:id])\n @historials =@cartucho.historials\n @historial = Historial.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cartucho }\n end\n end",
"def show\n @analyst = Analyst.find(params[:id])\n\n render json: @analyst\n end",
"def show\n render json: @quiz\n end",
"def index\n chapters = @project.chapters.all\n render json: { chapters: chapters }\n end",
"def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end",
"def show\n @moresmallmobsquad = Moresmallmobsquad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallmobsquad }\n end\n end",
"def show\n @politicalcommittee = Politicalcommittee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @politicalcommittee }\n end\n end"
] |
[
"0.6961569",
"0.6517356",
"0.644197",
"0.64323044",
"0.64267725",
"0.64141005",
"0.63896364",
"0.63785464",
"0.6346586",
"0.6204286",
"0.6171063",
"0.6140138",
"0.60529745",
"0.6052364",
"0.60214853",
"0.5986348",
"0.5982835",
"0.5974955",
"0.59725136",
"0.5959132",
"0.59407574",
"0.5938095",
"0.5936526",
"0.59346586",
"0.59303176",
"0.5924358",
"0.59188867",
"0.5916896",
"0.59104145",
"0.584206",
"0.5833346",
"0.5805335",
"0.57894194",
"0.5768104",
"0.57626194",
"0.57546335",
"0.5744145",
"0.5739792",
"0.57394004",
"0.572954",
"0.5712223",
"0.5712223",
"0.57119846",
"0.57103056",
"0.5696622",
"0.56954014",
"0.56942767",
"0.567502",
"0.567275",
"0.56624234",
"0.56536645",
"0.56499684",
"0.5644007",
"0.5640775",
"0.56305593",
"0.5624626",
"0.56230444",
"0.5619322",
"0.5605837",
"0.55988955",
"0.55910087",
"0.55876476",
"0.5584911",
"0.55841076",
"0.5583902",
"0.55794245",
"0.55769384",
"0.5573256",
"0.5573256",
"0.5570206",
"0.5566052",
"0.55652696",
"0.5563195",
"0.55619055",
"0.5557816",
"0.5556948",
"0.5554016",
"0.5551178",
"0.555014",
"0.55415225",
"0.5540843",
"0.5539966",
"0.5521568",
"0.5520906",
"0.5519669",
"0.5516357",
"0.55126107",
"0.55086255",
"0.55085236",
"0.55070996",
"0.55049527",
"0.5504327",
"0.5504327",
"0.5504327",
"0.5504121",
"0.55007386",
"0.5499743",
"0.5496757",
"0.5489599",
"0.5488292",
"0.54838353"
] |
0.0
|
-1
|
POST /quandaries POST /quandaries.json
|
def create
@quandary= current_user.quandaries.build(quandary_params)
respond_to do |format|
if @quandary.save
format.html { redirect_to @quandary, notice: 'Quandary was successfully created.' }
format.json { render :show, status: :created, location: @quandary }
else
format.html { render :new }
format.json { render json: @quandary.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def quandary_params\n params.require(:quandary).permit(:title, :description, :rating, :image)\n end",
"def create\n @quize = Quize.new(params[:quize])\n\n respond_to do |format|\n if @quize.save\n format.html { redirect_to @quize, notice: 'Quize was successfully created.' }\n format.json { render json: @quize, status: :created, location: @quize }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiniela = Quiniela.new(params[:quiniela])\n\n respond_to do |format|\n if @quiniela.save\n format.html { redirect_to @quiniela, notice: 'Quiniela was successfully created.' }\n format.json { render json: @quiniela, status: :created, location: @quiniela }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quiniela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qux = Qux.new(qux_params)\n\n respond_to do |format|\n if @qux.save\n format.html { redirect_to @qux, notice: 'Qux was successfully created.' }\n format.json { render :show, status: :created, location: @qux }\n else\n format.html { render :new }\n format.json { render json: @qux.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quay = Quay.new(params[:quay])\n\n respond_to do |format|\n if @quay.save\n flash[:notice] = 'Quay was successfully created.'\n format.html { redirect_to(@quay) }\n format.xml { render :xml => @quay, :status => :created, :location => @quay }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quay.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @q = Q.new(params[:q])\n\n respond_to do |format|\n if @q.save\n format.html { redirect_to @q, notice: 'Q was successfully created.' }\n format.json { render json: @q, status: :created, location: @q }\n else\n format.html { render action: \"new\" }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quarto = Quarto.new(quarto_params)\n\n respond_to do |format|\n if @quarto.save\n format.html { redirect_to @quarto, notice: 'Quarto was successfully created.' }\n format.json { render :show, status: :created, location: @quarto }\n else\n format.html { render :new }\n format.json { render json: @quarto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categoria_quarto = CategoriaQuarto.new(categoria_quarto_params)\n\n respond_to do |format|\n if @categoria_quarto.save\n format.html { redirect_to @categoria_quarto, notice: 'Categoria quarto was successfully created.' }\n format.json { render :show, status: :created, location: @categoria_quarto }\n else\n format.html { render :new }\n format.json { render json: @categoria_quarto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quatum = Quatum.new(quatum_params)\n\n respond_to do |format|\n if @quatum.save\n format.html { redirect_to @quatum, notice: 'Quatum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quatum }\n else\n format.html { render action: 'new' }\n format.json { render json: @quatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qurriculum = current_user.qurriculums.new(params[:qurriculum])\n\n respond_to do |format|\n if @qurriculum.save\n format.html { redirect_to @qurriculum, notice: 'Qurriculum was successfully created.' }\n format.json { render json: @qurriculum, status: :created, location: @qurriculum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qurriculum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qor = Qor.new(qor_params)\n\n respond_to do |format|\n if @qor.save\n format.html { redirect_to @qor, notice: 'Qor was successfully created.' }\n format.json { render :show, status: :created, location: @qor }\n else\n format.html { render :new }\n format.json { render json: @qor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @q = Q.new(q_params)\n\n respond_to do |format|\n if @q.save\n format.html { redirect_to @q, notice: 'Q was successfully created.' }\n format.json { render action: 'show', status: :created, location: @q }\n else\n format.html { render action: 'new' }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quartet = Quartet.new(params[:quartet])\n\n respond_to do |format|\n if @quartet.save\n format.html { redirect_to @quartet, notice: 'Quartet was successfully created.' }\n format.json { render json: @quartet, status: :created, location: @quartet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qanda = Qanda.new(params[:qanda])\n\n respond_to do |format|\n if @qanda.save\n format.html { redirect_to @qanda, notice: 'Q & A was successfully created.' }\n format.json { render json: @qanda, status: :created, location: @qanda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qanda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_quandary\n @quandary = Quandary.find(params[:id])\n end",
"def destroy\n @quandary.destroy\n respond_to do |format|\n format.html { redirect_to quandaries_url, notice: 'Quandary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @quartier = Quartier.new(params[:quartier])\n\n respond_to do |format|\n if @quartier.save\n format.html { redirect_to @quartier, notice: 'Quartier was successfully created.' }\n format.json { render json: @quartier, status: :created, location: @quartier }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quartier.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @altoq = Altoq.new(altoq_params)\n\n respond_to do |format|\n if @altoq.save\n format.html { redirect_to @altoq, notice: 'Altoq was successfully created.' }\n format.json { render :show, status: :created, location: @altoq }\n else\n format.html { render :new }\n format.json { render json: @altoq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quack = Quack.new(quack_params)\n\n respond_to do |format|\n if @quack.save\n format.html { redirect_to @quack, notice: 'Quack was successfully created.' }\n format.json { render :show, status: :created, location: @quack }\n else\n format.html { render :new }\n format.json { render json: @quack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n questions_arr.each do |i|\n question = Question.new(question_params(i))\n choices_arr(i).each do |j|\n choice = Choice.new(choice_params(j))\n choice.save\n question.choices << choice\n end\n @quiz.questions << question\n end\n\n if @quiz.save\n User.find(params[:user_id]).quizzes << @quiz\n render json: @quiz, status: :created, location: @quiz\n else\n render json: @quiz.errors, status: :unprocessable_entity\n end\n end",
"def index\n @quandaries = Quandary.all\n end",
"def test_submit_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: '123456', quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end",
"def create\n @quartet = Quartet.new(quartet_params)\n\n respond_to do |format|\n if @quartet.save\n format.html { redirect_to @quartet, notice: 'Quartet was successfully created.' }\n format.json { render :show, status: :created, location: @quartet }\n else\n format.html { render :new }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quaderni = Quaderni.new(quaderni_params)\n\n respond_to do |format|\n if @quaderni.save\n format.html { redirect_to quaderni_url(@quaderni), notice: \"Quaderni was successfully created.\" }\n format.json { render :show, status: :created, location: @quaderni }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quaderni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiebre = Quiebre.new(quiebre_params)\n\n respond_to do |format|\n if @quiebre.save\n format.html { redirect_to @quiebre, notice: 'Quiebre was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quiebre }\n else\n format.html { render action: 'new' }\n format.json { render json: @quiebre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_submit\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: SAMPLE_UDPRN, quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end",
"def create\n @qa = Qa.new(params[:qa])\n\n respond_to do |format|\n if @qa.save\n format.html { redirect_to @qa, notice: 'Qa was successfully created.' }\n format.json { render json: @qa, status: :created, location: @qa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Neo4j::Transaction.run do\n @q_resource = QResource.new(params[:q_resource])\n @q_resource.save!\n respond_to do |format|\n if @q_resource.save\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully created.' }\n format.json { render :json => @q_resource, :status => :created, :location => @q_resource }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def create\n\t\t\tquiz = Quiz.new(quiz_params)\n\t\t\tif quiz.save\n\t\t\t\tcurrent_instructor.quizzes << quiz\n\t\t\t\trender json: { id: quiz.id }, status: 201\n\t\t\telse\n\t\t\t\trender json: { error: quiz.errors }, status: 422\n\t\t\tend\n\t\tend",
"def create\n @quize = Quize.new(quize_params)\n @quize.user_id = current_user.id\n respond_to do |format|\n if @quize.save\n format.html { redirect_to edit_quize_path(@quize), notice: 'Quize was successfully created.' }\n format.json { render :show, status: :created, location: @quize }\n else\n format.html { render :new }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@questionary = Questionary.new(questionary_params)\n\n\t\trespond_to do |format|\n\t\t\tif @questionary.save\n\t\t\t\tformat.html { redirect_to '/questionary_items/new/' + @questionary.id.to_s }\n\t\t\t\tformat.json { render :show, status: :created, location: @questionary }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @questionary.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @aquarium = Aquarium.new(params[:aquarium])\n\n respond_to do |format|\n if @aquarium.save\n format.html { redirect_to @aquarium, notice: 'Aquarium was successfully created.' }\n format.json { render json: @aquarium, status: :created, location: @aquarium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @aquarium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qa = Qa.new(qa_params)\n\n respond_to do |format|\n if @qa.save\n format.html { redirect_to @qa, notice: 'Qa was successfully created.' }\n format.json { render :show, status: :created, location: @qa }\n else\n format.html { render :new }\n format.json { render json: @qa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def liquor_params\n params.require(:liquor).permit(:name, :brand, :proof)\n end",
"def create\n @quadra = Quadra.new(quadra_params)\n respond_to do |format|\n if @quadra.save\n format.html { redirect_to quadras_url, notice: 'Quadra criada com sucesso.' }\n format.json { render :show, status: :created, location: @quadra }\n else\n format.html { render :new }\n format.json { render json: @quadra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def qux_params\n params.require(:qux).permit(:name)\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def quatum_params\n params.require(:quatum).permit(:service_request_id, :user_id, :amount, :duration, :when, :state)\n end",
"def create\n @completed_quest = CompletedQuest.new(params[:completed_quest])\n\n respond_to do |format|\n if @completed_quest.save\n format.html { redirect_to @completed_quest, notice: 'Completed quest was successfully created.' }\n format.json { render json: @completed_quest, status: :created, location: @completed_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @completed_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n workout = Workout.find params[:workout_id]\n result = Question.create(workout, { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n @question = result[:question]\n\n respond_to do |format|\n unless @question.persisted?\n format.json { render :json => @question.errors.full_messages, :status => :unprocessable_entity }\n else\n format.json { render :json => @question.as_json({:include => :answers}) }\n end\n \n end\n\n end",
"def create\n # puts params\n questions = JSON.parse(params[:questions])\n q_hash = questions[\"questions\"]\n @assignment = Assignment.new\n @assignment.course_id = params[:course_id]\n @assignment.type = \"Homework\"\n @assignment.start_date = params[:start_date]\n @assignment.end_date = params[:end_date]\n @assignment.name = params[:name]\n # Following is the question hash\n q_hash.each do |key, value|\n a_hash = key[\"answers\"]\n question = key[\"question\"]\n puts question\n new_question = Question.new\n new_question.description = question\n new_question.type = \"MultipleChoice\"\n # Answer hash\n a_hash.each do |k,v|\n puts k[\"is_correct\"]\n puts k[\"description\"]\n new_answer = Answer.new\n new_answer.description = k[\"description\"]\n new_answer.is_correct = k[\"is_correct\"]\n new_question.association(:answers).add_to_target(new_answer)\n end\n @assignment.association(:questions).add_to_target(new_question)\n end\n \n if @assignment.save\n render :show, status: :created, location: @assignment\n else\n render json: @assignment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @marquage = Marquage.new(marquage_params)\n\n if @marquage.save\n render :show, status: :created, location: @marquage\n else\n render json: @marquage.errors, status: :unprocessable_entity\n end\n end",
"def test_new_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n prev_quote_count = Agents::Branches::AssignedAgents::Quote.count\n post :new, params_hash\n assert_response 200\n assert_equal Agents::Branches::AssignedAgents::Quote.count, (prev_quote_count + 1)\n end",
"def test_new\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n prev_quote_count = Agents::Branches::AssignedAgents::Quote.count\n post :new, params_hash\n assert_response 200\n assert_equal Agents::Branches::AssignedAgents::Quote.count, (prev_quote_count + 1)\n end",
"def create\n @queencell = Queencell.new(params[:queencell])\n\n respond_to do |format|\n if @queencell.save\n format.html { redirect_to @queencell, notice: 'Queencell was successfully created.' }\n format.json { render json: @queencell, status: :created, location: @queencell }\n else\n format.html { render action: \"new\" }\n format.json { render json: @queencell.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n \n respond_to do |format|\n if @room.save\n trivia_category = (@room.category.eql? \"any\") ? '' : \"category=\" + @room.category\n \n questions_response = RestClient::Request.execute(\n method: :get,\n url: 'https://opentdb.com/api.php?amount=7&type=multiple&' + trivia_category\n )\n questions = JSON.parse(questions_response)['results']\n\n questions.each do |question|\n Question.create(\n :problem => question['question'],\n :category => question['category'],\n :correct_answer => question[\"correct_answer\"],\n :incorrect_answer_one => question[\"incorrect_answers\"][0],\n :incorrect_answer_two => question[\"incorrect_answers\"][1],\n :incorrect_answer_three => question[\"incorrect_answers\"][2],\n :room_id => @room.id\n )\n end\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quest = Quest.new(quest_params)\n respond_to do |format|\n if @quest.save\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render :show, status: :created, location: @quest }\n else\n format.html { render :new }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quetion = Quetion.new(params[:quetion])\n\n respond_to do |format|\n if @quetion.save\n format.html { redirect_to @quetion, notice: 'Quetion was successfully created.' }\n format.json { render json: @quetion, status: :created, location: @quetion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quetion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @arquife = Arquive.new(arquife_params)\n\n respond_to do |format|\n if @arquife.save\n format.html { redirect_to @arquife, notice: 'Arquive was successfully created.' }\n format.json { render :show, status: :created, location: @arquife }\n else\n format.html { render :new }\n format.json { render json: @arquife.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend",
"def create\n @quotation_unit = QuotationUnit.new(quotation_unit_params)\n\n respond_to do |format|\n if @quotation_unit.save\n format.html { redirect_to @quotation_unit, notice: 'Quotation unit was successfully created.' }\n format.json { render :show, status: :created, location: @quotation_unit }\n else\n format.html { render :new }\n format.json { render json: @quotation_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quack_params\n params.require(:quack).permit(:name, :title)\n end",
"def create\n @tutorial_quest = Tutorial::Quest.new(params[:tutorial_quest])\n\n respond_to do |format|\n if @tutorial_quest.save\n format.html { redirect_to @tutorial_quest, notice: 'Quest was successfully created.' }\n format.json { render json: @tutorial_quest, status: :created, location: @tutorial_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutorial_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quandary.update(quandary_params)\n format.html { redirect_to @quandary, notice: 'Quandary was successfully updated.' }\n format.json { render :show, status: :ok, location: @quandary }\n else\n format.html { render :edit }\n format.json { render json: @quandary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quarter = Quarter.new(params[:quarter])\n\n respond_to do |format|\n if @quarter.save\n format.html { redirect_to(@quarter, :notice => 'Quarter was successfully created.') }\n format.xml { render :xml => @quarter, :status => :created, :location => @quarter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quarter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend",
"def create\n @qishi = Qishi.new(qishi_params)\n\n respond_to do |format|\n if @qishi.save\n format.html { redirect_to @qishi, notice: 'Qishi was successfully created.' }\n format.json { render :show, status: :created, location: @qishi }\n else\n format.html { render :new }\n format.json { render json: @qishi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question\n else\n render status: 400, nothing: true\n end\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend",
"def create\n @quotation = Quotation.new(quotation_params)\n authorize @quotation\n respond_to do |format|\n if @quotation.save\n format.html { redirect_to @quotation, notice: 'Quotation was successfully created.' }\n format.json { render :show, status: :created, location: @quotation }\n else\n format.html { render :new }\n format.json { render json: @quotation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiver = Quiver.new(quiver_params)\n\n respond_to do |format|\n if @quiver.save\n format.html { redirect_to @quiver, notice: 'Quiver was successfully created.' }\n format.json { render :show, status: :created, location: @quiver }\n else\n format.html { render :new }\n format.json { render json: @quiver.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quarto_params\n params.require(:quarto).permit(:numero, :piso)\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend",
"def create\n @quip = Quip.new(params[:quip])\n\n respond_to do |format|\n if @quip.save\n format.html { redirect_to @quip, notice: 'Quip was successfully created.' }\n format.json { render json: @quip, status: :created, location: @quip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quinto = Quinto.new(quinto_params)\n \n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n respond_to do |format|\n if @quinto.save\n format.html { redirect_to @quinto, notice: 'Quinto was successfully created.' }\n format.json { render :show, status: :created, location: @quinto }\n else\n format.html { render :new }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qb = Qb.new(qb_params)\n\n respond_to do |format|\n if @qb.save\n format.html { redirect_to @qb, notice: 'Qb was successfully created.' }\n format.json { render :show, status: :created, location: @qb }\n else\n format.html { render :new }\n format.json { render json: @qb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quclity_check = QuclityCheck.new(quclity_check_params)\n @quclity_check.save\n redirect_to \"/plans/spread/1\"\n \n end",
"def create\n @equity = Equity.new(equity_params)\n\n respond_to do |format|\n if @equity.save\n format.html { redirect_to @equity, notice: 'Equity was successfully created.' }\n format.json { render :show, status: :created, location: @equity }\n else\n format.html { render :new }\n format.json { render json: @equity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agronomiaquimica = Agronomiaquimica.new(params[:agronomiaquimica])\n\n respond_to do |format|\n if @agronomiaquimica.save\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully created.' }\n format.json { render json: @agronomiaquimica, status: :created, location: @agronomiaquimica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quizz_params\n params.require(:quizz).permit(:title, :description, :difficulty)\n end",
"def create\n @quadra = Quadra.new(quadra_params)\n\n respond_to do |format|\n if @quadra.save\n format.html { redirect_to @quadra, notice: 'Quadra was successfully created.' }\n format.json { render :show, status: :created, location: @quadra }\n else\n format.html { render :new }\n format.json { render json: @quadra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bloque = Bloque.new(params[:bloque])\n\n if @bloque.save\n render json: @bloque, status: :created, location: @bloque\n else\n render json: @bloque.errors, status: :unprocessable_entity\n end\n end",
"def quize_params\n params.require(:quize).permit(:name, :user_id, questions_attributes: [:id,:name, :answer,:_destroy, options_attributes: [:id,:name,:_destroy, :is_correct]] )\n end",
"def create\n @questao = Questao.new(questao_params)\n\n respond_to do |format|\n if @questao.save\n format.html { redirect_to @questao, notice: 'Questao was successfully created.' }\n format.json { render :show, status: :created, location: @questao }\n else\n format.html { render :new }\n format.json { render json: @questao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quadrant_params\n params.require(:quadrant).permit(:bracket_id, :name, :order)\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n @quiz.refrence_id = @quiz.id\n @quiz.save\n format.json { render json: @quiz.show_full_details }\n else\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @squad = Squad.new(squad_params)\n\n respond_to do |format|\n if @squad.save\n format.html { redirect_to @squad, notice: 'Squad was successfully created.' }\n format.json { render :show, status: :created, location: @squad }\n else\n format.html { render :new }\n format.json { render json: @squad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @paroquia = Paroquia.new(params[:paroquia])\n\n respond_to do |format|\n if @paroquia.save\n flash[:notice] = 'Paroquia was successfully created.'\n format.html { redirect_to(@paroquia) }\n format.xml { render :xml => @paroquia, :status => :created, :location => @paroquia }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @paroquia.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end",
"def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quote_id=>@quote.id}\n\n # respond_to do |format|\n # if @quote.save\n # format.html { redirect_to index, notice: 'Quote was successfully created.' }\n # # format.json { render action: 'show', status: :created, location: @quote }\n # else\n # format.html { render action: 'new' }\n # # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\nend",
"def create\n @qanda = Qanda.new(params[:qanda])\n @qanda.creator = current_user\n\n respond_to do |format|\n if @qanda.save\n format.html { redirect_to @qanda, notice: 'Qanda was successfully created.' }\n format.json { render json: @qanda, status: :created, location: @qanda }\n else\n flash[:alert] = \"Qanda has not been created.\"\n format.html { render action: \"new\" }\n format.json { render json: @qanda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enqury = Enqury.new(enqury_params)\n\n respond_to do |format|\n if @enqury.save\n format.html { redirect_to @enqury, notice: 'Enqury was successfully created.' }\n format.json { render :show, status: :created, location: @enqury }\n else\n format.html { render :new }\n format.json { render json: @enqury.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def create\n @question = Question.create!(question_params.merge({user_id: 1}))\n if question_params[:answers]\n question_params[:answers].with_indifferent_access.each do |answer|\n Answer.create!(name: answer[:name], question_id: @question.id)\n end\n end\n @question.prepare\n @question.broadcast\n render json: @question, status: :created\n end",
"def create\n @user_quest = UserQuest.new(params[:user_quest])\n\n respond_to do |format|\n if @user_quest.save\n format.html { redirect_to @user_quest, notice: 'User quest was successfully created.' }\n format.json { render json: @user_quest, status: :created, location: @user_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quaderni_params\n params.require(:quaderni).permit(:title, :release_date, :file_doc, speaker_ids: [])\n end",
"def create\n @pharmacy = Pharmacy.new(pharmacy_params)\n respond_to do |format|\n if @pharmacy.save\n format.json { render :show, status: :created, location: @pharmacy }\n else\n format.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @maquinat = Maquinat.new(maquinat_params)\n\n respond_to do |format|\n if @maquinat.save\n format.html { redirect_to @maquinat, notice: 'Maquinat was successfully created.' }\n format.json { render :show, status: :created, location: @maquinat }\n else\n format.html { render :new }\n format.json { render json: @maquinat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quadrant = Quadrant.new(quadrant_params)\n\n respond_to do |format|\n if @quadrant.save\n format.html { redirect_to @quadrant, notice: 'Quadrant was successfully created.' }\n format.json { render :show, status: :created, location: @quadrant }\n else\n format.html { render :new }\n format.json { render json: @quadrant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create body = {}\n @connection.request(method: :post, path: \"/secrets/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def create\n @quizzes_answer = Quizzes::Answer.new(quizzes_answer_params)\n\n respond_to do |format|\n if @quizzes_answer.save\n format.html { redirect_to @quizzes_answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @quizzes_answer }\n else\n format.html { render :new }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categoria_quotum = CategoriaQuotum.new(categoria_quotum_params)\n\n respond_to do |format|\n if @categoria_quotum.save\n format.html { redirect_to @categoria_quotum, notice: 'Categoria quotum was successfully created.' }\n format.json { render :show, status: :created, location: @categoria_quotum }\n else\n format.html { render :new }\n format.json { render json: @categoria_quotum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(body)\n raise ArgumentError unless body.is_a?(Hash)\n\n api.post('', body, 'application/json')\n end",
"def create(body)\n raise ArgumentError unless body.is_a?(Hash)\n\n api.post('', body, 'application/json')\n end",
"def create(body)\n raise ArgumentError unless body.is_a?(Hash)\n\n api.post('', body, 'application/json')\n end"
] |
[
"0.62389404",
"0.62389404",
"0.6151092",
"0.61087877",
"0.6073034",
"0.6004367",
"0.593869",
"0.5891279",
"0.58522236",
"0.5834811",
"0.58176064",
"0.57938856",
"0.5793638",
"0.57666874",
"0.57587105",
"0.575488",
"0.57460207",
"0.57189983",
"0.56820595",
"0.5674164",
"0.5650449",
"0.5639124",
"0.56365526",
"0.56172645",
"0.5615613",
"0.55999136",
"0.55641323",
"0.55372787",
"0.5524854",
"0.5517448",
"0.5477386",
"0.5461009",
"0.54609936",
"0.5430235",
"0.5428949",
"0.53792506",
"0.5375996",
"0.53757024",
"0.5356338",
"0.53563136",
"0.5348073",
"0.5341735",
"0.53395957",
"0.53385866",
"0.5323084",
"0.5322403",
"0.53163296",
"0.53131944",
"0.53125036",
"0.5306746",
"0.5305381",
"0.5269574",
"0.5268487",
"0.52683294",
"0.52645034",
"0.52530164",
"0.5235355",
"0.523361",
"0.5224783",
"0.5221672",
"0.5213325",
"0.5205383",
"0.51964563",
"0.51910025",
"0.5188573",
"0.5185395",
"0.51796615",
"0.51783866",
"0.5176175",
"0.5169973",
"0.51683736",
"0.5167804",
"0.51627254",
"0.5160104",
"0.5159919",
"0.51453584",
"0.51416683",
"0.5134961",
"0.51253426",
"0.51193684",
"0.51191664",
"0.5114394",
"0.51131976",
"0.5106899",
"0.5099336",
"0.5097543",
"0.50972116",
"0.5080957",
"0.50800973",
"0.50727934",
"0.5071143",
"0.50565284",
"0.50546277",
"0.50525695",
"0.5050523",
"0.50501394",
"0.50459284",
"0.5042137",
"0.5042137",
"0.5042137"
] |
0.7157882
|
0
|
PATCH/PUT /quandaries/1 PATCH/PUT /quandaries/1.json
|
def update
respond_to do |format|
if @quandary.update(quandary_params)
format.html { redirect_to @quandary, notice: 'Quandary was successfully updated.' }
format.json { render :show, status: :ok, location: @quandary }
else
format.html { render :edit }
format.json { render json: @quandary.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @qu = Qu.find(params[:id])\n respond_to do |format|\n if @qu.update_attributes(params[:qu])\n format.html { redirect_to @qu, :notice => 'Qu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @qu = Qu.find(params[:id])\n respond_to do |format|\n if @qu.update_attributes(params[:qu])\n format.html { redirect_to @qu, :notice => 'Qu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n if @quiniela.update_attributes(params[:quiniela])\n format.html { redirect_to @quiniela, notice: 'Quiniela was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quiniela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quatum.update(quatum_params)\n format.html { redirect_to @quatum, notice: 'Quatum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @qux.update(qux_params)\n format.html { redirect_to @qux, notice: 'Qux was successfully updated.' }\n format.json { render :show, status: :ok, location: @qux }\n else\n format.html { render :edit }\n format.json { render json: @qux.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quay = Quay.find(params[:id])\n\n respond_to do |format|\n if @quay.update_attributes(params[:quay])\n flash[:notice] = 'Quay was successfully updated.'\n format.html { redirect_to(@quay) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quay.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @quize = Quize.find(params[:id])\n\n respond_to do |format|\n if @quize.update_attributes(params[:quize])\n format.html { redirect_to @quize, notice: 'Quize was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quack.update(quack_params)\n format.html { redirect_to @quack, notice: 'Quack was successfully updated.' }\n format.json { render :show, status: :ok, location: @quack }\n else\n format.html { render :edit }\n format.json { render json: @quack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quartier = Quartier.find(params[:id])\n\n respond_to do |format|\n if @quartier.update_attributes(params[:quartier])\n format.html { redirect_to @quartier, notice: 'Quartier was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quartier.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @q = Q.find_by_unique_id(params[:id])\n\n respond_to do |format|\n if @q.update_attributes(params[:q])\n format.html { redirect_to @q, notice: 'Q was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quartet = Quartet.find(params[:id])\n\n respond_to do |format|\n if @quartet.update_attributes(params[:quartet])\n format.html { redirect_to @quartet, notice: 'Quartet was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quclity_check.update(quclity_check_params)\n format.html { redirect_to @quclity_check, notice: 'Quclity check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quclity_check.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quize.update(quize_params)\n format.html { redirect_to @quize, notice: 'Quize was successfully updated.' }\n format.json { render :show, status: :ok, location: @quize }\n else\n format.html { render :edit }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quarto.update(quarto_params)\n format.html { redirect_to @quarto, notice: 'Quarto was successfully updated.' }\n format.json { render :show, status: :ok, location: @quarto }\n else\n format.html { render :edit }\n format.json { render json: @quarto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @q.update(q_params)\n format.html { redirect_to @q, notice: 'Q was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n if @quarter.update_attributes(params[:quarter])\n format.html { redirect_to @quarter, notice: 'Quarter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quarter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quartet.update(quartet_params)\n format.html { redirect_to @quartet, notice: 'Quartet was successfully updated.' }\n format.json { render :show, status: :ok, location: @quartet }\n else\n format.html { render :edit }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @qor.update(qor_params)\n format.html { redirect_to @qor, notice: 'Qor was successfully updated.' }\n format.json { render :show, status: :ok, location: @qor }\n else\n format.html { render :edit }\n format.json { render json: @qor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end",
"def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @qanda = Qanda.find(params[:id])\n\n respond_to do |format|\n if @qanda.update_attributes(params[:qanda])\n format.html { redirect_to @qanda, notice: 'Q & A was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qanda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @arquife.update(arquife_params)\n format.html { redirect_to @arquife, notice: 'Arquive was successfully updated.' }\n format.json { render :show, status: :ok, location: @arquife }\n else\n format.html { render :edit }\n format.json { render json: @arquife.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @aquarium = Aquarium.find(params[:id])\n\n respond_to do |format|\n if @aquarium.update_attributes(params[:aquarium])\n format.html { redirect_to @aquarium, notice: 'Aquarium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aquarium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Neo4j::Transaction.run do\n @q_resource = QResource.find(params[:id])\n @q_resource.update_attributes!(params[:q_resource])\n respond_to do |format|\n if @q_resource.update_attributes(params[:q_resource])\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n question = Question.find_by!(id: params[:id])\n if question\n question.name = params[:name]\n question.description = params[:description]\n question.user_id = params[:user_id]\n question.category_id = params[:category_id]\n question.zavrseno = params[:zavrseno]\n question.uposlenik_id = params[:uposlenik_id]\n question.save\n render json: question, status: 200 \n else\n render json: { errors: \"This link is invalid.\"}, status: 404\n end\n end",
"def update\n @qa = Qa.find(params[:id])\n\n respond_to do |format|\n if @qa.update_attributes(params[:qa])\n format.html { redirect_to @qa, notice: 'Qa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @questionary.update(questionary_params)\n\t\t\t\tformat.html { redirect_to @questionary, notice: 'Questionary was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @questionary }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @questionary.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n if @quantity.update_attributes(params[:quantity])\n format.html { redirect_to @quantity, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n if @quantity.update_attributes(params[:quantity])\n format.html { redirect_to @quantity, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @qurriculum = current_user.qurriculums.find(params[:id])\n\n respond_to do |format|\n if @qurriculum.update_attributes(params[:qurriculum])\n format.html { redirect_to @qurriculum, notice: 'Qurriculum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qurriculum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n if @quest.update_attributes(params[:quest])\n format.html { redirect_to @quest, notice: 'Quest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_single_poll(id,polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @quaderni.update(quaderni_params)\n format.html { redirect_to quaderni_url(@quaderni), notice: \"Quaderni was successfully updated.\" }\n format.json { render :show, status: :ok, location: @quaderni }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @quaderni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @altoq.update(altoq_params)\n format.html { redirect_to @altoq, notice: 'Altoq was successfully updated.' }\n format.json { render :show, status: :ok, location: @altoq }\n else\n format.html { render :edit }\n format.json { render json: @altoq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend",
"def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def update\n respond_to do |format|\n if @quiebre.update(quiebre_params)\n format.html { redirect_to @quiebre, notice: 'Quiebre was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quiebre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n respond_to do |format|\n if @quake.update(quake_params)\n format.html { redirect_to @quake, notice: 'Quake was successfully updated.' }\n format.json { render :show, status: :ok, location: @quake }\n else\n format.html { render :edit }\n format.json { render json: @quake.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end",
"def update\n respond_to do |format|\n if @qishi.update(qishi_params)\n format.html { redirect_to @qishi, notice: 'Qishi was successfully updated.' }\n format.json { render :show, status: :ok, location: @qishi }\n else\n format.html { render :edit }\n format.json { render json: @qishi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_question.update(api_v1_question_params)\n format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_question }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update #saves and redirects, saves changes\n @line_item = LineItem.find(params[:id])\n @line_item.quantity = params[:quantity]\n @line_item.size_id = params[:size_id]\n @line_item.save\n render json: @line_item\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def update\n respond_to do |format|\n if @quizzes_question.update(quizzes_question_params)\n if params[:commit] =~ /add/i\n format.html { redirect_to edit_quiz_question_path(@question.quiz, @question) }\n else\n format.html { redirect_to quiz_questions_path(@question.quiz), notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @quizzes_question }\n end\n else\n format.html { render :edit }\n format.json { render json: @quizzes_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n @question.update_attributes(params[:question])\n render :json => @question.id if @question.save\n # respond_to do |format|\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n # end\n # end\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update\n respond_to do |format|\n if @quest.update(quest_params)\n format.html { redirect_to @quest, notice: 'Quest was successfully updated.' }\n format.json { render :show, status: :ok, location: @quest }\n else\n format.html { render :edit }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @questao.update(questao_params)\n format.html { redirect_to @questao, notice: 'Questao was successfully updated.' }\n format.json { render :show, status: :ok, location: @questao }\n else\n format.html { render :edit }\n format.json { render json: @questao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quip = Quip.find(params[:id])\n\n respond_to do |format|\n if @quip.update_attributes(params[:quip])\n format.html { redirect_to @quip, notice: 'Quip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n @requisition = Requisition.find(params[:id])\n\n respond_to do |format|\n if @requisition.update_attributes(params[:requisition])\n format.html { redirect_to @requisition, notice: 'Requisition was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n return\n respond_to do |format|\n if @quest.update(quest_params)\n format.html { redirect_to @quest, notice: 'Quest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @categoria_quarto.update(categoria_quarto_params)\n format.html { redirect_to @categoria_quarto, notice: 'Categoria quarto was successfully updated.' }\n format.json { render :show, status: :ok, location: @categoria_quarto }\n else\n format.html { render :edit }\n format.json { render json: @categoria_quarto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update\n respond_to do |format|\n if @rfq.update(rfq_params)\n format.html { redirect_to @rfq, notice: 'Request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rfq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update\n @queencell = Queencell.find(params[:id])\n\n respond_to do |format|\n if @queencell.update_attributes(params[:queencell])\n format.html { redirect_to @queencell, notice: 'Queencell was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @queencell.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n if @quarter.update_attributes(params[:quarter])\n format.html { redirect_to(@quarter, :notice => 'Quarter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quarter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def patch!\n request! :patch\n end",
"def update\n @rnaseq = Rnaseq.find(params[:id])\n\n respond_to do |format|\n if @rnaseq.update_attributes(params[:rnaseq])\n format.html { redirect_to @rnaseq, notice: 'Rnaseq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rnaseq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update\n #@question = Question.find(params[:id])\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: t('alert.question.update_success', default: 'Question was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invoice = Invoice.find(params[:id])\n title=params['q_param']['title']\n total=params['q_param']['total']\n tax_rate=params['q_param']['tax_rate']\n l=params['q_param']['list']\n comment=params['q_param']['comment']\n list=Array.new\n l.keys.each do |j|\n list << [l[j][0],l[j][1],l[j][2],l[j][3]]\n end\n invoice={:title=>title,:total=>total,:list=>list,:tax_rate=>tax_rate,:comment=>comment}\n @invoice.update(invoice)\n format.json { head :no_content }\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end",
"def update\n respond_to do |format|\n if @special_requirement.update(special_requirement_params)\n format.html { redirect_to @special_requirement, notice: 'Special requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_requirement }\n else\n format.html { render :edit }\n format.json { render json: @special_requirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end",
"def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end",
"def update\n # @bill_quorum = BillQuorum.find(params[:id])\n\n respond_to do |format|\n if @bill_quorum.update_attributes(params[:bill_quorum])\n format.html { redirect_to @bill_quorum, notice: 'Bill Quorum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bill_quorum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @q_response = QResponse.find(params[:id])\n\n respond_to do |format|\n if @q_response.update_attributes(params[:q_response])\n format.html { redirect_to @q_response, notice: 'Q response was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @q_response.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend",
"def update\n p = trial_params.clone\n if p[\"question_ids\"].nil?\n p[\"question_ids\"] = []\n end\n\n respond_to do |format|\n if @trial.update(p)\n format.html { redirect_to @trial, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quetion = Quetion.find(params[:id])\n\n respond_to do |format|\n if @quetion.update_attributes(params[:quetion])\n format.html { redirect_to @quetion, notice: 'Quetion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quetion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz43.update(baz43_params)\n format.html { redirect_to @baz43, notice: \"Baz43 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz43 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz43.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_quandary\n @quandary = Quandary.find(params[:id])\n end",
"def update\n @squawk = Squawk.find(params[:id])\n\n respond_to do |format|\n if @squawk.update_attributes(params[:squawk])\n format.html { redirect_to @squawk, notice: 'Squawk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squawk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo34.update(foo34_params)\n format.html { redirect_to @foo34, notice: \"Foo34 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo34 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo34.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6535625",
"0.6535625",
"0.6463256",
"0.6404475",
"0.6357032",
"0.6356482",
"0.63205767",
"0.63128835",
"0.6258589",
"0.6254157",
"0.62235",
"0.61985064",
"0.6196127",
"0.6118855",
"0.6104543",
"0.60871434",
"0.6069321",
"0.606445",
"0.6039602",
"0.60374117",
"0.60209024",
"0.6020629",
"0.60098547",
"0.597106",
"0.59613734",
"0.5958888",
"0.5935951",
"0.59255457",
"0.5917658",
"0.5913268",
"0.5907867",
"0.5897033",
"0.58949554",
"0.58949554",
"0.58909583",
"0.58857006",
"0.58594924",
"0.58550906",
"0.58450437",
"0.58422685",
"0.58141845",
"0.5807969",
"0.57998097",
"0.5797516",
"0.5795922",
"0.57897216",
"0.5789082",
"0.57870704",
"0.577135",
"0.57647216",
"0.5755484",
"0.5751675",
"0.5744038",
"0.57439137",
"0.5736142",
"0.5735028",
"0.57320553",
"0.5718589",
"0.5718086",
"0.571567",
"0.57152194",
"0.5714171",
"0.5710873",
"0.5709846",
"0.570577",
"0.57054913",
"0.5700019",
"0.56890804",
"0.56865364",
"0.56850064",
"0.5678177",
"0.56780106",
"0.56768996",
"0.56761163",
"0.56709456",
"0.56680244",
"0.56659824",
"0.5662728",
"0.56625",
"0.56625",
"0.5660291",
"0.56581527",
"0.56551594",
"0.5655059",
"0.5652294",
"0.56489855",
"0.5645485",
"0.5644425",
"0.56439495",
"0.5643713",
"0.56429386",
"0.56420875",
"0.5641568",
"0.5638629",
"0.5636151",
"0.56265706",
"0.56210166",
"0.5617962",
"0.5615413",
"0.5613386"
] |
0.69665366
|
0
|
DELETE /quandaries/1 DELETE /quandaries/1.json
|
def destroy
@quandary.destroy
respond_to do |format|
format.html { redirect_to quandaries_url, notice: 'Quandary was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @quatum.destroy\n respond_to do |format|\n format.html { redirect_to quata_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qu = Qu.find(params[:id])\n @qu.destroy\n\n respond_to do |format|\n format.html { redirect_to qus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quiniela = Quiniela.find(params[:id])\n @quiniela.destroy\n\n respond_to do |format|\n format.html { redirect_to quinielas_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @qu = Qu.find(params[:id])\n @qu.destroy\n respond_to do |format|\n format.html { redirect_to qus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aquarium = Aquarium.find(params[:id])\n @aquarium.destroy\n\n respond_to do |format|\n format.html { redirect_to aquaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quay = Quay.find(params[:id])\n @quay.destroy\n\n respond_to do |format|\n format.html { redirect_to(quays_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @qux.destroy\n respond_to do |format|\n format.html { redirect_to quxes_url, notice: 'Qux was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quartier = Quartier.find(params[:id])\n @quartier.destroy\n\n respond_to do |format|\n format.html { redirect_to quartiers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qa = Qa.find(params[:id])\n @qa.destroy\n\n respond_to do |format|\n format.html { redirect_to qas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quize = Quize.find(params[:id])\n @quize.destroy\n\n respond_to do |format|\n format.html { redirect_to quizes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quartet = Quartet.find(params[:id])\n @quartet.destroy\n\n respond_to do |format|\n format.html { redirect_to quartets_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @quclity_check.destroy\n respond_to do |format|\n format.html { redirect_to quclity_checks_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @quinto.destroy\n respond_to do |format|\n format.html { redirect_to quintos_url, notice: 'Quinto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quize.destroy\n respond_to do |format|\n format.html { redirect_to quizes_url, notice: 'Quize was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qanda = Qanda.find(params[:id])\n @qanda.destroy\n\n respond_to do |format|\n format.html { redirect_to qandas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @q = Q.find_by_unique_id(params[:id])\n @q.destroy\n\n respond_to do |format|\n format.html { redirect_to qs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thought = Thought.find(params[:id])\n @quast = @thought.quastion\n @thought.destroy\n\n respond_to do |format|\n format.html { redirect_to quastion_path(@quast) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quest = Quest.find(params[:id])\n @quest.destroy\n\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @arquife.destroy\n respond_to do |format|\n format.html { redirect_to arquives_url, notice: 'Arquive was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quaderni.destroy\n\n respond_to do |format|\n format.html { redirect_to quadernis_url, notice: \"Quaderni was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @qurriculum = current_user.qurriculums.find(params[:id])\n @qurriculum.destroy\n\n respond_to do |format|\n format.html { redirect_to qurriculums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rnaseq = Rnaseq.find(params[:id])\n @rnaseq.destroy\n\n respond_to do |format|\n format.html { redirect_to rnaseqs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n # render plain: @disqux.inspect\n @disqux.destroy\n respond_to do |format|\n format.html { redirect_to project_disquxes_path(@project), notice: 'Disqux was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quartet.destroy\n respond_to do |format|\n format.html { redirect_to quartets_url, notice: 'Quartet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(*rest) end",
"def destroy\n @altoq.destroy\n respond_to do |format|\n format.html { redirect_to altoqs_url, notice: 'Altoq was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @q.destroy\n respond_to do |format|\n format.html { redirect_to qs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quantity = Quantity.find(params[:id])\n @quantity.destroy\n\n respond_to do |format|\n format.html { redirect_to quantities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quantity = Quantity.find(params[:id])\n @quantity.destroy\n\n respond_to do |format|\n format.html { redirect_to quantities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quarto.destroy\n respond_to do |format|\n format.html { redirect_to quartos_url, notice: 'Quarto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @quiebre.destroy\n respond_to do |format|\n format.html { redirect_to quiebres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @completed_quest = CompletedQuest.find(params[:id])\n @completed_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to completed_quests_url }\n format.json { head :ok }\n end\n end",
"def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end",
"def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quotation.destroy\n respond_to do |format|\n format.html { redirect_to quotations_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @qor.destroy\n respond_to do |format|\n format.html { redirect_to qors_url, notice: 'Qor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baz1.destroy\n respond_to do |format|\n format.html { redirect_to baz1s_url, notice: \"Baz1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n return\n @quest.destroy\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quake.destroy\n respond_to do |format|\n format.html { redirect_to quakes_url, notice: 'Quake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @qa.destroy\n respond_to do |format|\n format.html { redirect_to qas_url, notice: 'Qa was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n sql = \"DELETE FROM albums WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend",
"def destroy\n @requisition = Requisition.find(params[:id])\n @requisition.destroy\n\n respond_to do |format|\n format.html { redirect_to requisitions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxirequest = Taxirequest.find(params[:id])\n @taxirequest.destroy\n\n respond_to do |format|\n format.html { redirect_to taxirequests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @squish = Squish.find(params[:id])\n @squish.destroy\n \n respond_to do |format|\n format.html { redirect_to squishes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @questao.destroy\n respond_to do |format|\n format.html { redirect_to questaos_url, notice: 'Questao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @squawk = Squawk.find(params[:id])\n @squawk.destroy\n\n respond_to do |format|\n format.html { redirect_to squawks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qanda.destroy\n\n respond_to do |format|\n flash[:notice] = 'Qanda was successfully deleted.'\n format.html { redirect_to qandas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quest.destroy\n respond_to do |format|\n format.html { redirect_to quests_url, notice: 'Quest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quack.destroy\n respond_to do |format|\n format.html { redirect_to quacks_url, notice: 'Quack was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qb.destroy\n respond_to do |format|\n format.html { redirect_to qbs_url, notice: 'Qb was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qa = Qa.find(params[:id])\n @qa.destroy\n\n respond_to do |format|\n format.html { redirect_to(qas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @qa = Qa.find(params[:id])\n @qa.destroy\n\n respond_to do |format|\n format.html { redirect_to(qas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quest = Quest.find(params[:id])\n @quest.destroy\n\n respond_to do |format|\n format.html { redirect_to(quests_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @quotation = Quotation.find(params[:id])\n @quotation.destroy\n\n respond_to do |format|\n format.html { redirect_to(quotations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @planitem = Planitem.find(params[:id])\n\tqtrname = @planitem.sprint.quarter.name\n @planitem.destroy\n\n respond_to do |format|\n format.html { redirect_to plan_path(qtrname) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @q_response = QResponse.find(params[:id])\n @q_response.destroy\n\n respond_to do |format|\n format.html { redirect_to q_responses_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @categoria_quarto.destroy\n respond_to do |format|\n format.html { redirect_to categoria_quarto_index_url, notice: 'Categoria quarto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n @quest_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_quest_items_url, notice: 'Всё норм' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qupon.destroy\n respond_to do |format|\n format.html { redirect_to qupons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quetion = Quetion.find(params[:id])\n @quetion.destroy\n\n respond_to do |format|\n format.html { redirect_to quetions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxinomy = Taxinomy.find(params[:id])\n @taxinomy.destroy\n\n respond_to do |format|\n format.html { redirect_to taxinomies_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n sql = \"DELETE FROM albums\n WHERE id = $1;\"\n values = [@id]\n SqlRunner.run( sql, values )\n end",
"def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qa_client = QaClient.find(params[:id])\n @qa_client.destroy\n\n respond_to do |format|\n format.html { redirect_to qa_clients_url }\n format.json { head :no_content }\n end\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n #na real, cada question pertence a um quiz, basta achar a question de mesma id\n @qq = QuizQuestion.where(question: @question)\n @qq.destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @muscle_diary.destroy\n respond_to do |format|\n format.html { redirect_to muscle_diaries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unique_whiteline.destroy\n respond_to do |format|\n format.html { redirect_to unique_whitelines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quadra.destroy\n respond_to do |format|\n format.html { redirect_to quadras_url, notice: 'Quadra was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quadrant.destroy\n respond_to do |format|\n format.html { redirect_to quadrants_url, notice: 'Quadrant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end"
] |
[
"0.71185946",
"0.7070663",
"0.70522606",
"0.7052003",
"0.69715416",
"0.69682944",
"0.6847839",
"0.68292654",
"0.6829206",
"0.68079275",
"0.6757404",
"0.6745749",
"0.6730558",
"0.6705325",
"0.6683369",
"0.6668477",
"0.6653593",
"0.6652635",
"0.6635347",
"0.66319096",
"0.66288805",
"0.6622517",
"0.65938896",
"0.6592429",
"0.6577347",
"0.6576689",
"0.6559608",
"0.6531213",
"0.65264064",
"0.6519486",
"0.65168166",
"0.65154755",
"0.6513884",
"0.651338",
"0.6505713",
"0.6505713",
"0.6502467",
"0.6492389",
"0.64922106",
"0.64864576",
"0.64846677",
"0.6482781",
"0.64816946",
"0.6470377",
"0.64645827",
"0.6461783",
"0.6454037",
"0.64539385",
"0.64520544",
"0.644874",
"0.6445027",
"0.64335626",
"0.64278114",
"0.6425967",
"0.6416371",
"0.6416083",
"0.64144224",
"0.6414151",
"0.6412771",
"0.6408237",
"0.64078677",
"0.64062065",
"0.6405682",
"0.6395416",
"0.63939524",
"0.6388657",
"0.63882405",
"0.63848114",
"0.63843185",
"0.6379074",
"0.6379074",
"0.63782555",
"0.6363507",
"0.63625014",
"0.63600004",
"0.63570887",
"0.63554215",
"0.63552874",
"0.6347856",
"0.63454896",
"0.6344937",
"0.6341414",
"0.6340004",
"0.63357663",
"0.633256",
"0.63298225",
"0.63294077",
"0.63291407",
"0.632656",
"0.6325276",
"0.63233197",
"0.63226116",
"0.6321614",
"0.6321273",
"0.6319629",
"0.6319629",
"0.6319518",
"0.6316368",
"0.6316368",
"0.6316368"
] |
0.7315046
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_quandary
@quandary = Quandary.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def quandary_params
params.require(:quandary).permit(:title, :description, :rating, :image)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Formats a CarbonDate::Date with year precision as a string Returns: A humanreadable string representing the Date
|
def year(date)
y = date.year.abs.to_s
return [y, BCE_SUFFIX].join(' ') if (date.year <= -1)
y
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format_year(year)\n \"#{year}-#{year+1}\"\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def year\n date&.strftime('%Y')\n end",
"def w_year\n @obj.date.strftime(\"%G\")\n end",
"def sortable_year_for_yyyy\n matches = orig_date_str.match(/\\d{4}/) if orig_date_str\n matches.to_s if matches\n end",
"def to_s\n fy = first.year.to_s\n end_year = last.year\n fy += \"-\" + end_year.to_s unless first.year == end_year\n fy\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def raw_year\n start_on.year\n end",
"def build_header_year\n \"#{begin_date.year}/#{end_date.year}\"\n end",
"def format_date(date)\n if date.nil?\n return \"\"\n end\n if date.year == Date.today.year\n return date.strftime(\"%A, %B %-d\") unless date.nil?\n else\n return date.strftime(\"%A, %B %-d %Y\") unless date.nil?\n end\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def year\n created.strftime '%Y'\n end",
"def get_year_with_number\n date_receipt.strftime(\"%Y\") + \"-\" + sprintf( \"%03i\", receipt_num )\n end",
"def year\n 2020\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def year_name(number); end",
"def year_name(number)\n if year_format_lambda = @options[:year_format]\n year_format_lambda.call(number)\n else\n number\n end\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def to_s\n \"FiscalYear #{ year }: #{ fd(days.first) } to #{ fd(days.last) }\"\n end",
"def to_date(date, year)\n Date.parse(\"#{date}-#{year}\")\n end",
"def year_display_str(date_el_array)\n result = date_parsing_result(date_el_array, :date_str_for_display)\n return result if result\n\n _ignore, orig_str_to_parse = self.class.earliest_year_str(date_el_array)\n DateParsing.date_str_for_display(orig_str_to_parse) if orig_str_to_parse\n end",
"def year\n #Para que salga con el formato de ARG\n fecha = Date.parse(self.created_at.to_s)\n fecha.strftime('%Y')\n end",
"def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n start_year.to_s\n else\n start_year.to_s + '-' + end_year.to_s\n end\n end",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def new_year(date) = ::Date.new(Integer === date ? date : date(date).year, 1, 1, reform_jd).new_start(::Date::GREGORIAN)",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend",
"def yn(year)\n return year if year.size == 4\n\n y = Date.today.year.to_s[2..4].to_i + 1\n case year.to_i\n when 0...y then \"20#{year}\"\n when y..99 then \"19#{year}\"\n end\n end",
"def format_date(year, month = 1, day = 1)\n format_year(year) + format_month(month) + format_day(day)\n end",
"def year\n Time.zone.now.year\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def as_date( d = nil )\n d = (d || self)\n return '' unless [Date, Time, DateTime].include? d.class\n format = d.year == Date.today.year ? 'date_same_year' : 'date_other_year'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def year() end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def to_year\n month_obj = []\n month_obj << \"#{month_name}\".center(DEFAULT_MONTH_WIDTH)\n month_obj << \"Su Mo Tu We Th Fr Sa\"\n month_obj.concat(format_body)\n end",
"def get_number_with_year\n receipt_num.to_s + \" / \" + get_date_receipt().strftime(\"%Y\")\n end",
"def year\n @date_time_value.year\n end",
"def year\n @date_time_value.year\n end",
"def date\n \"#{day} #{month.capitalize} #{year}\"\n end",
"def to_s\n \"#{'%04i' % year}-W#{'%02i' % index}\"\n end",
"def todays_year_stamp()\n d = Time.now.strftime(\"%Y\")\n d\nend",
"def to_s\n txt = name\n txt += \" (#{self.year})\" if self.year && self.year > 0\n return txt\n end",
"def translate_date\n (self.origin_date).strftime(\"%b %Y\")\n end",
"def full_academic_year\n unless academic_year.blank?\n academic_year.to_s + '-' + (academic_year + 1).to_s\n end\n end",
"def to_string\n return @year.to_s + \" \" + @month.to_s + \" \" + @day.to_s\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def this_year\n year(Time.now)\n end",
"def year; end",
"def year; end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def comment_year(datetime)\n datetime.year != DateTime.now.year ? \"#{datetime.year} \" : \"\"\n end",
"def pub_year_display_str(ignore_approximate = false)\n single_pub_year(ignore_approximate, :year_display_str)\n\n # TODO: want range displayed when start and end points\n # TODO: also want best year in year_isi fields\n # get_main_title_date\n # https://github.com/sul-dlss/SearchWorks/blob/7d4d870a9d450fed8b081c38dc3dbd590f0b706e/app/helpers/results_document_helper.rb#L8-L46\n\n # \"publication_year_isi\" => \"Publication date\", <-- do it already\n # \"beginning_year_isi\" => \"Beginning date\",\n # \"earliest_year_isi\" => \"Earliest date\",\n # \"earliest_poss_year_isi\" => \"Earliest possible date\",\n # \"ending_year_isi\" => \"Ending date\",\n # \"latest_year_isi\" => \"Latest date\",\n # \"latest_poss_year_isi\" => \"Latest possible date\",\n # \"production_year_isi\" => \"Production date\",\n # \"original_year_isi\" => \"Original date\",\n # \"copyright_year_isi\" => \"Copyright date\"} %>\n\n # \"creation_year_isi\" => \"Creation date\", <-- do it already\n # {}\"release_year_isi\" => \"Release date\",\n # {}\"reprint_year_isi\" => \"Reprint/reissue date\",\n # {}\"other_year_isi\" => \"Date\",\n end",
"def sortable_year_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n return $1 + '00' if $1.length == 2\n return '0' + $1 + '00' if $1.length == 1\n end\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n if century_str_matches\n yy = ($1.to_i - 1).to_s\n return yy + '00' if yy.length == 2\n return '0' + yy + '00' if yy.length == 1\n end\n end",
"def format_date_nicely(date)\nend",
"def publication_year(field = nil)\n IsoYear.cast(find_record_items(field).first)&.to_s if field\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def year\n @created_at.year\n end",
"def century_year(year)\n\n\tcentury_year = year.div(100) + 1\n\tcentury_year -= 1 if year % 100 == 0\n\tcentury_year.to_s + century_suffix(century_year)\n\nend",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def to_s\n \"#{@month}/#{@day}/#{@year}\"\n end",
"def born_date\n super.to_s(:long)\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def century(year)\n num = (year - 1) / 100 + 1\n century = num.to_s + suffix(num)\nend",
"def to_year(**options) = convert_to('year', **options)",
"def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n \"\\#{start_year}\"\n else\n \"\\#{start_year}–\\#{end_year}\"\n end\n end",
"def year(input) = new_year(input).year - 621",
"def display_date\n if self.publication_date\n if self.volume && self.issue\n # just the year, ma'am\n I18n.localize(self.publication_date, :format => \"%Y\")\n else\n # whole date, since we got it\n I18n.localize(self.publication_date, :format => \"%d %b %Y\")\n end\n elsif self.year\n self.year.to_s\n else\n nil\n end\n end",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def fmt_date(date)\n if (date)\n date.strftime(\"%m-%d-%Y\")\n end\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def year\n @year ||= TODAY.year\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def to_s\n\t\tMonth.month_names[@month-1][0..2] + \" \" + @year.to_s\n\tend",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def get_built_year\n return @built_year\n end",
"def sortable_year_for_yy\n return unless orig_date_str\n\n slash_matches = orig_date_str.match(/\\d{1,2}\\/\\d{1,2}\\/\\d{2}/)\n if slash_matches\n date_obj = Date.strptime(orig_date_str, '%m/%d/%y')\n else\n hyphen_matches = orig_date_str.match(/\\d{1,2}-\\d{1,2}-\\d{2}/)\n date_obj = Date.strptime(orig_date_str, '%m-%d-%y') if hyphen_matches\n end\n if date_obj && date_obj > Date.today\n date_obj = Date.new(date_obj.year - 100, date_obj.month, date_obj.mday)\n end\n date_obj.year.to_s if date_obj\n rescue ArgumentError\n nil # explicitly want nil if date won't parse\n end",
"def year_day\n self.created_at.strftime('%Y %j')\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def first_year\n 2012\n end",
"def js_year(year)\n [year,1,1].compact.join(',')\n end",
"def fiscal_year_on_date(date)\n fiscal_year(fiscal_year_year_on_date(date))\n end",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def year\n (seconds_since_epoch / Y_SECS).to_i\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def sortable_year_str_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n ($1.to_i - 1000).to_s if bc_matches\n end",
"def inspect\n \"the year is \" + humanize_list(@years)\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def ano\n Date.today.strftime('%y')\n end",
"def year\n end",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def century(year)\n century = (year / 100) + 1\n century -= 1 if year % 100 == 0\n \n century.to_s + century_suffix(century)\nend",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def current_year\n Time.current.year\n end",
"def name_author_year_string\n [name, author_year_string].compact.join(\" \")\n end",
"def date\n \"#{self[:day]}_#{self[:month]}_#{self[:year]}\"\n end"
] |
[
"0.7263901",
"0.70944643",
"0.70578635",
"0.68968964",
"0.6865473",
"0.6822611",
"0.68086827",
"0.68062824",
"0.680387",
"0.6730236",
"0.6712811",
"0.6666544",
"0.6627725",
"0.66246295",
"0.6560978",
"0.64972436",
"0.6484851",
"0.64819336",
"0.64819336",
"0.6473761",
"0.64682746",
"0.6462084",
"0.6426979",
"0.64089197",
"0.6376127",
"0.63627535",
"0.63509345",
"0.63453114",
"0.63186055",
"0.6314502",
"0.6299553",
"0.62847936",
"0.6281724",
"0.62538165",
"0.62536323",
"0.6249124",
"0.6245205",
"0.6235702",
"0.62321454",
"0.62321454",
"0.6227856",
"0.62205744",
"0.6217115",
"0.62118906",
"0.6206277",
"0.6198265",
"0.6188104",
"0.618331",
"0.6165152",
"0.6164562",
"0.6164562",
"0.6160079",
"0.6159126",
"0.61516297",
"0.61509246",
"0.6147389",
"0.61426204",
"0.6141041",
"0.61360735",
"0.6135763",
"0.6124272",
"0.61144215",
"0.61083794",
"0.6105408",
"0.60929173",
"0.6085299",
"0.6078665",
"0.6077796",
"0.60650456",
"0.6061593",
"0.60570866",
"0.60567266",
"0.6045535",
"0.6042012",
"0.6033615",
"0.6029119",
"0.6028961",
"0.6027319",
"0.6026334",
"0.6021311",
"0.6016708",
"0.60112077",
"0.60099953",
"0.60068834",
"0.60025454",
"0.5996115",
"0.5984718",
"0.59819293",
"0.59811085",
"0.5980566",
"0.5975624",
"0.5975468",
"0.5973112",
"0.59631085",
"0.5963017",
"0.59569114",
"0.5956641",
"0.5949509",
"0.5948038",
"0.5947706"
] |
0.6805639
|
8
|
Formats a CarbonDate::Date with month precision as a string Returns: A humanreadable string representing the Date
|
def month(date)
[MONTHS[date.month - 1], year(date)].join(', ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end",
"def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end",
"def month\n @month.to_s.rjust(2, '0')\n end",
"def month_str\n ret = Datet.months(:trans => true)[@t_month]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def month\n start_on.strftime(MONTH_NAME)\n end",
"def create_date_month_day\n\t\tcreated_at.to_date.to_formatted_s(:short)\n\tend",
"def month_name\n report_date.strftime(\"%B\")\n end",
"def month_name(the_date)\n Date::MONTHNAMES[the_date.month]\n end",
"def month_to_name\n month = Date.new(Time.now.year, purchased_at_month.to_i)\n month.strftime(\"%B\")\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def month\n start_date&.strftime('%b %Y')\n end",
"def format_month(month)\n month.to_s.insert(0, \"0\") unless month.to_s.length == 2\n end",
"def month\n self.founded.strftime(\"%B\")\n end",
"def name_of_month(style = :full)\n @time.strftime(style == :full ? \"%B\" : \"%b\")\n end",
"def month_name(number); end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def spelled_out_for_date(date)\n %w[%B %b].map { |month| date.strftime(\"#{month} %Y\") }\n end",
"def mn(month)\n n = Date::ABBR_MONTHNAMES.index(month) || Date::MONTHNAMES.index(month)\n return month unless n\n\n n.to_s.rjust 2, \"0\"\n end",
"def month_result_string(day)\n start = day.beginning_of_month.yday - 1\n finish = day.end_of_month.yday - 1\n result_string(day.year).slice(start..finish)\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def month\n created.strftime '%m'\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def month_depot\n \"#{depot.name} \"+\"#{issue_date.strftime(\"%b\")} \"+\"#{issue_date.year}\"\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def get_month(month)\n month = month.to_s\n month.length == 2 ? month : \"0#{month}\"\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def to_s\n\t\tMonth.month_names[@month-1][0..2] + \" \" + @year.to_s\n\tend",
"def number_to_short_month_name(number)\n sliced_month_name = number_to_full_month_name(number).slice(0,3)\n return sliced_month_name\nend",
"def number_to_short_month_name(month)\n return number_to_full_month_name(month)[0..2]\nend",
"def number_to_short_month_name(n)\n short_month_string = number_to_full_month_name(n)[0..2]\nend",
"def month_number\n date.month\n end",
"def month_label\n \"#{label}\"\n end",
"def day_of_month\n start_on.day.to_s\n end",
"def month() end",
"def month_name\n I18n.t('date.month_names')[month_number].camelize\n end",
"def number_to_short_month_name(a)\n return number_to_full_month_name(a).slice(0,3)\nend",
"def to_s\n \"#{@month}/#{@day}/#{@year}\"\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def date_move_formatter\n '%Y-%m'\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def number_to_full_month_name(month_number)\n return Date::MONTHNAMES[month_number]\nend",
"def month_names; end",
"def format_dates\n days = (1..@number_of_days_in_month).to_a\n days.map! do |d|\n d < 10 ? \" \" + d.to_s : d.to_s\n end\n # adds blank elements to the beginning of the days array to offset the\n # first day of the month\n @first_day_of_month.times do\n blankday = \" \"\n days.unshift(blankday)\n end\n days\n end",
"def number_to_full_month_name(month_number)\n require \"date\"\n return Date::MONTHNAMES[month_number]\nend",
"def number_to_short_month_name(month)\n short_name = number_to_full_month_name(month)\n return short_name.slice(0,3)\nend",
"def number_to_full_month_name(num)\n return Date::MONTHNAMES[num]\nend",
"def current_month\n Time.now.strftime(\"%^b\")\n end",
"def current_month\n \tDate.today.strftime(\"%B\")\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def month_labels\n dates.collect { |date| date.to_date.day == 1 ? date.to_date.strftime('%B') : '' }\n end",
"def date\n \"#{day} #{month.capitalize} #{year}\"\n end",
"def month\n Thread.current[:datet_mode] = :months\n return @t_month\n end",
"def to_month(**options) = convert_to('month', **options)",
"def month; end",
"def month; end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def monthstamp(year, month)\n \"#{year}#{month.to_s.rjust(2, \"0\")}\".to_i\nend",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end",
"def time_month; Time.now.month; end",
"def number_to_short_month_name(month)\n if month == 1\n return \"Jan\"\n elsif month == 2\n return \"Feb\"\n elsif month == 3\n return \"Mar\"\n elsif month == 4\n return \"Apr\"\n elsif month == 5\n return \"May\"\n elsif month == 6\n return \"Jun\"\n elsif month == 7\n return \"Jul\"\n elsif month == 8\n return \"Aug\"\n elsif month == 9\n return \"Sep\"\n elsif month == 10\n return \"Oct\"\n elsif month == 11\n return \"Nov\"\n elsif month == 12\n return \"Dec\"\n else\n return \"This does not correlate to a month\"\n end\nend",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def number_to_short_month_name(month)\n full_month = number_to_full_month_name(month)\n short_month_name = full_month.slice(0, 3)\n #short_month_name = full_month[0..2] *ARRAY VERSION\n return short_month_name\nend",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def print_month\n print \"#{@month.capitalize} #{@year}\".center(20) + \" \"\n puts \"\\n\"\n print \"Su Mo Tu We Th Fr Sa\" + \" \"\n puts \"\\n\"\n format_month_body.each do |line|\n converted_line = line.map do |day|\n day.to_s.rjust(2)\n end\n puts converted_line.join(\" \") + \" \"\n end\n end",
"def month_name(number)\n if @options[:use_month_numbers]\n number\n elsif @options[:use_two_digit_numbers]\n \"%02d\" % number\n elsif @options[:add_month_numbers]\n \"#{number} - #{month_names[number]}\"\n elsif format_string = @options[:month_format_string]\n format_string % { number: number, name: month_names[number] }\n else\n month_names[number]\n end\n end",
"def number_to_full_month_name(month)\n case month\n when 1\n month = \"January\"\n when 2\n month = \"February\"\n when 3\n month = \"March\"\n when 4\n month = \"April\"\n when 5\n month = \"May\"\n when 6\n month = \"June\"\n when 7\n month = \"July\"\n when 8\n month = \"August\"\n when 9\n month = \"September\"\n when 10\n month = \"October\"\n when 11\n month = \"November\"\n when 12\n month = \"December\"\n end\nreturn month\nend",
"def calendar_month_header date\n \"#{I18n.translate('date.month_names')[date.month]} #{date.year}\"\n end",
"def roman_month(date)\n date[1]\n end",
"def month_arg_to_s(m)\n month_array = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n month_array[m - 1]\nend",
"def month\n @date_time_value.month\n end",
"def month\n @date_time_value.month\n end",
"def to_s\n [today, future, past, other_month].compact.join(\" \")\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def number_to_short_month_name(month_number)\n result = number_to_full_month_name(month_number)\n return result[0,3]\nend",
"def number_to_full_month_name(month)\n if month == 1\n return \"January\"\n elsif month == 2\n return \"February\"\n elsif month == 3\n return \"March\"\n elsif month == 4\n return \"April\"\n elsif month == 5\n return \"May\"\n elsif month == 6\n return \"June\"\n elsif month == 7\n return \"July\"\n elsif month == 8\n return \"August\"\n elsif month == 9\n return \"September\"\n elsif month == 10\n return \"October\"\n elsif month == 11\n return \"November\"\n elsif month == 12\n return \"December\"\n else\n return \"This does not correlate to a month\"\n end\nend",
"def number_to_short_month_name(month_number)\n require \"date\"\n return Date::ABBR_MONTHNAMES[month_number]\nend",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def month_name\n return @@month_names[@t_month]\n end",
"def number_to_short_month_name(month_number)\n short_month = number_to_full_month_name(month_number)\n return short_month[0..2]\nend",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def translated_month_names; end",
"def number_to_short_month_name(num)\n month = number_to_full_month_name(num)\n return month [0..2]\nend",
"def month\n @month ||= date_calc.merch_to_julian(merch_month)\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def format_date_nicely(date)\nend",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end"
] |
[
"0.70175797",
"0.70175797",
"0.6908569",
"0.68976855",
"0.67848736",
"0.67848736",
"0.67518467",
"0.6716134",
"0.6712761",
"0.6684678",
"0.66814077",
"0.66467375",
"0.66138846",
"0.6593557",
"0.65671486",
"0.65501297",
"0.65374804",
"0.6481884",
"0.6475689",
"0.64270544",
"0.6404487",
"0.6375772",
"0.63691276",
"0.6360931",
"0.6336336",
"0.6332768",
"0.63227695",
"0.6291979",
"0.6291979",
"0.6291979",
"0.6291979",
"0.6291979",
"0.6265873",
"0.62651235",
"0.62577116",
"0.6244747",
"0.6230455",
"0.6218946",
"0.6214934",
"0.62063324",
"0.620217",
"0.61868197",
"0.6179757",
"0.6166168",
"0.616575",
"0.61576277",
"0.6157251",
"0.6147321",
"0.6139638",
"0.6137454",
"0.61312425",
"0.61213857",
"0.6107801",
"0.6098002",
"0.60888165",
"0.6085745",
"0.6083355",
"0.60797673",
"0.6063633",
"0.60634243",
"0.6058669",
"0.60553735",
"0.6041003",
"0.6041003",
"0.60379076",
"0.6027281",
"0.602291",
"0.59902",
"0.5984617",
"0.5964864",
"0.5960792",
"0.59511703",
"0.5949399",
"0.5948934",
"0.594821",
"0.59435153",
"0.59215045",
"0.5918497",
"0.5907704",
"0.588416",
"0.5874048",
"0.5874048",
"0.58682793",
"0.5862023",
"0.58615714",
"0.5856992",
"0.58562994",
"0.5850936",
"0.58490777",
"0.5848768",
"0.58457655",
"0.58427197",
"0.5841403",
"0.58306664",
"0.58302027",
"0.5821555",
"0.58139914",
"0.5811799",
"0.58088744",
"0.57937634"
] |
0.6518905
|
17
|
Formats a CarbonDate::Date with day precision as a string Returns: A humanreadable string representing the Date
|
def day(date)
[date.day.ordinalize.to_s, month(date)].join(' ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def formatted_date\n \"#{self.day.date.strftime(\"%A, %B %e, %Y\")}\"\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def format_date_nicely(date)\nend",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def date_str d\n Util::date(d)\n end",
"def to_s\n find.to_s.strftime(Day::DATE_FORMAT)\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end",
"def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def utc_day_str\n self.datetime.strftime(\"%A\")\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def nice_day string\r\n string = string.to_s\r\n return convert_day_to_date(string).strftime('%A, %B %e, %Y') if string.length == 8\r\n return Date.new(string).strftime('%A, %B %e, %Y')\r\n end",
"def format_date( date = Date.today )\n date.strftime('%a %d/%m/%Y')\n end",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def pretty_date(date)\n if date.today?\n return t(:today)\n elsif date.to_date == Date.yesterday\n return t(:yesterday)\n else\n return date.strftime(\"%b %d, %Y\")\n end\n end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def db_formatted_d( d )\n# d.try( :to_formatted_s, :db_date )\n d&.to_formatted_s( :db_date )\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def format_date(date)\n year, month, day, day_name, hour = [\n date.year,\n Date::MONTHNAMES[date.month],\n date.day.ordinalize,\n date.strftime(\"%A\"),\n convert_hour(date.hour, 'standard')\n ]\n\n \"#{day_name} #{month} #{day}, #{year} at #{hour}\"\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def format_human_readable_date(date)\n case date.to_date\n when Time.zone.today.to_date\n 'Today'\n when Time.zone.tomorrow\n 'Tomorrow'\n when Time.zone.yesterday\n 'Yesterday'\n else\n l(date, format: :short)\n end\n end",
"def to_s\n mday.to_s\n end",
"def getDateString(d)\n return d.strftime('%Y-%-m-%-d')\nend",
"def to_date string\n \n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def date_to_s\n self.date.strftime(\"%B %d, %Y\")\n end",
"def to_s\n \"#{@date.to_s}: #{@text}\"\n end",
"def to_s\n s = (to_s_pieces(DATE_FIELDS) + [to_s_time_piece]).compact.join(' ')\n if s == \"\"\n \"0 days\"\n else\n s\n end + (ago ? \" ago\" : \"\")\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def date\n \"#{day} #{month.capitalize} #{year}\"\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def formatted_date(date)\n DateTime.parse(date).strftime('%-m/%-d/%y')\n rescue\n ''\n end",
"def date_to_day date\r\n date = Date.parse(date) unless date.respond_to? :strftime\r\n return date.strftime('%Y%m%d')\r\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def date\n \"#{self[:day]}_#{self[:month]}_#{self[:year]}\"\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def format_date_to_s(val)\n Date.parse(val.to_s).strftime('%m/%d/%Y')\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def to_s\n \"#{@month}/#{@day}/#{@year}\"\n end",
"def fmt_date(date)\n if (date)\n date.strftime(\"%m-%d-%Y\")\n end\n end",
"def geek_date(date)\n date.strftime(\"%Y-%m-%d\") \n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def quoted_date(value)\n super.to_s\n end",
"def fmt_dow_date(dt) _format_dt dt, DOW_M_D end",
"def create_date_month_day\n\t\tcreated_at.to_date.to_formatted_s(:short)\n\tend",
"def fmt_date(dt)\n if dt.present?\n dt.strftime(ApplicationHelper.date_fmt)\n end\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def format_date(year, month = 1, day = 1)\n format_year(year) + format_month(month) + format_day(day)\n end",
"def format_date(start_date, end_date = nil)\n dates = start_date.strftime('%D')\n dates << ' -- ' + end_date.strftime('%D') if end_date\n dates\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end",
"def to_s\n @date\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def date_str\n if self.jd.nil?\n return \"\"\n else\n Date.jd(self.jd).strftime(\"%B %d, %Y\")\n end\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def date_short(date)\n\t\tdate.strftime(\"%b %e, %Y\") if !date.blank?\n\tend",
"def dateize(date)\n if not date.nil?\n date.strftime(\"%Y-%m-%d\")\n end\nend",
"def format_date(date, format = \"%m/%d/%Y\")\n date.respond_to?(:strftime) ? date.strftime(format) : date.to_s\n end",
"def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end",
"def formatted_date\n \tobject.created_at.strftime(\"%R - %B %e, %Y \")\n end",
"def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end",
"def easy_date; date; end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def showdate(my_date)\n if my_date\n str_date=my_date.to_date.strftime(\"%d-%m-%Y\")\n else\n str_date=\"\"\n end\n return str_date\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def day_str(timezone = patient.timezone)\n parsed_time(timezone).strftime(\"%A\")\n end",
"def date\n dreport.date_format\n end",
"def date_dashes(d)\n d && d.length == 8 ? d.slice(0, 4) + \"-\" + d.slice(4, 2) + \"-\" + d.slice(6, 2) : d\n end",
"def date_format(date)\n\t if date\n\t date.strftime(\"%d/%m/%Y\")\n\t end\n\tend",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def date_view value, meta=nil\n return value.strftime \"%Y-%m-%d\" unless value.nil?\n ''\n end"
] |
[
"0.7418952",
"0.6998934",
"0.6885781",
"0.681611",
"0.67580223",
"0.6754108",
"0.67494404",
"0.67186266",
"0.6626139",
"0.6626139",
"0.6566078",
"0.65371704",
"0.6524665",
"0.65231633",
"0.652215",
"0.65159845",
"0.6490641",
"0.64803797",
"0.64725554",
"0.64614254",
"0.64463747",
"0.6441532",
"0.6441532",
"0.6439934",
"0.64243174",
"0.6419307",
"0.6391788",
"0.638157",
"0.6379981",
"0.63716996",
"0.6356054",
"0.63471836",
"0.63253546",
"0.6319986",
"0.631809",
"0.631479",
"0.63009596",
"0.6285702",
"0.62493426",
"0.62465405",
"0.624096",
"0.62401146",
"0.6239886",
"0.6226033",
"0.620879",
"0.620879",
"0.6200409",
"0.61919165",
"0.61919165",
"0.618647",
"0.61849725",
"0.6181617",
"0.617511",
"0.6170197",
"0.6143246",
"0.6132519",
"0.6132292",
"0.6132292",
"0.6132292",
"0.61185914",
"0.61161304",
"0.6113904",
"0.6113395",
"0.6113176",
"0.6099299",
"0.60918915",
"0.60905015",
"0.60868305",
"0.6080265",
"0.6078641",
"0.60748154",
"0.60710806",
"0.6069423",
"0.6066745",
"0.60654825",
"0.60615516",
"0.60600775",
"0.60529953",
"0.6032532",
"0.602574",
"0.6025612",
"0.6015782",
"0.6014985",
"0.6014378",
"0.60139227",
"0.60074806",
"0.5990629",
"0.5990051",
"0.5974742",
"0.5966188",
"0.59503335",
"0.59444046",
"0.59419614",
"0.5941597",
"0.59413195",
"0.5940475",
"0.59381586",
"0.59381586",
"0.59359694",
"0.5930655"
] |
0.59504145
|
90
|
Formats a CarbonDate::Date with hour precision as a string Returns: A humanreadable string representing the Date
|
def hour(date)
h = date.minute >= 30 ? date.hour + 1 : date.hour
time = [pad(h.to_s), '00'].join(':')
[time, day(date)].join(' ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_formatted_hour\n start_on.strftime(\"%H:%M\")\n end",
"def format_date(date)\n year, month, day, day_name, hour = [\n date.year,\n Date::MONTHNAMES[date.month],\n date.day.ordinalize,\n date.strftime(\"%A\"),\n convert_hour(date.hour, 'standard')\n ]\n\n \"#{day_name} #{month} #{day}, #{year} at #{hour}\"\n end",
"def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end",
"def formatted_date datetime\n return '' if datetime.nil?\n\n datetime.strftime '%Y-%m-%d %H:%m'\n end",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def show_in_strftime\n @date.strftime(\"%d/%m/%Y -- %H:%M\")\n end",
"def detail_date( date )\n date.strftime( '%H:%M - %b %d, %Y')\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def date_formatter(date)\n date_array = date.split(\":\")\n\n # Clean up formatting\n date_array.first.gsub!(\"T\", \" \")\n date_array.last.delete!(\"Z\")\n return_date = date_array.join(\":\")\n\n return_date << \" (UTC+0:00)\"\n end",
"def date_str(date)\n date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')\nend",
"def formatted_hours\n as_hours hours\n end",
"def formatted_hours\n as_hours hours\n end",
"def format_date_nicely(date)\nend",
"def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end",
"def to_string(t)\n t.respond_to?(:getutc) ? t.getutc.strftime(DATE_FORMAT) : t.strftime(DATE_FORMAT)\n end",
"def date(options = {})\n res = \"\"\n res += \"#{I18n.localize(self.starts_at, :format => '%A %d')} de \" if options[:include_week_day] != false\n res += \"#{I18n.localize(self.starts_at, :format => '%B')} de \" if options[:include_month] != false\n # TODO: hack hack hack 20 min\n res += \"#{self.starts_at.strftime(\"%H:%M\")} a #{self.ends_at.strftime(\"%H:%M\")}\"\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def decorated_created_at\n created_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def formatted_date\n \"#{self.day.date.strftime(\"%A, %B %e, %Y\")}\"\n end",
"def pretty_time\n\thour = created_at.strftime(\"%l\").to_i - 5\n\tcreated_at.strftime(\"%A, %b %d, %Y\")\nend",
"def H; cat @time.strftime('%H') end",
"def date_formate(date)\n return nil if date.blank?\n date.strftime('%m/%d/%Y %I:%M %p')\n end",
"def to_s\n \"#{hour.to_s.rjust(2, '0')}:#{minute.to_s.rjust(2, '0')}\"\n end",
"def dby_date(date)\n result = \"\"\n if date != nil\n result = date.strftime(\"%d %b %Y %H:%M\")\n end\n result\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def to_s\n format('%<hours>02dh%<minutes>02dm', hours: @hours, minutes: @minutes)\n end",
"def en_time_format(date)\n date.strftime(\"%m.%d.%y - %H:%M\")\n end",
"def to_s\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{formatted_offset(false, 'UTC')}\" # mimicking Ruby Time#to_s format\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def to_s\n if year == 0 and mon == 0 and day == 0\n h = neg ? hour * -1 : hour\n sprintf \"%02d:%02d:%02d\", h, min, sec\n else\n sprintf \"%04d-%02d-%02d %02d:%02d:%02d\", year, mon, day, hour, min, sec\n end\n end",
"def formatted_creation_date\n self.created_at.strftime(\"%b %d '%y %H:%M\")\n end",
"def formatted_created_at\n self.created_at.to_date.to_s(:long)\nend",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def dt_format\n \"%Y-%m-%d %H:%M\"\n end",
"def departure_date_formatted\n # self.departure_date.strftime \"%Y-%m-%d, %I:%M%P\"\n departure_date.strftime \"%Y-%m-%d, %I:%M%P\"\n\n end",
"def get_inspection_date\n date.strftime(\"%B %d, %Y, %I:%M %p\")\n end",
"def formatted_created_at\n article.created_at.strftime(\"%m/%d/%Y - %H:%M\")\n end",
"def to_s()\n\t\tself.to_chrono()\n\tend",
"def to_s\n \"#{@date.to_s}: #{@text}\"\n end",
"def formated_date( input, format=$date_format )\n if not format.nil? and not input.nil?\n res = ParseDate.parsedate( input )\n Time.local(*res).strftime( format )\n else\n input\n end\n end",
"def format_datetime(obj)\n return unless obj\n\n obj.strftime('%Y-%m-%d %H:%M')\n end",
"def time_to_str(dt)\r\n ret = nil\r\n if dt.nil?\r\n ret = \"\"\r\n else\r\n ret = dt.iso8601\r\n ret[10..-1] = \"Z\" if self.allday # yyyy-mm-ddZ\r\n end\r\n ret\r\n end",
"def to_s\n return \"#{location} #{purpose} #{hour} #{min} #{day}\"\n end",
"def to_s_for_cap\n to_datetime.to_s_for_cap\n end",
"def format_human_readable_date(date)\n case date.to_date\n when Time.zone.today.to_date\n 'Today'\n when Time.zone.tomorrow\n 'Tomorrow'\n when Time.zone.yesterday\n 'Yesterday'\n else\n l(date, format: :short)\n end\n end",
"def date\n # self.start_time.in_time_zone(self.school.timezone).strftime('%A - %-m/%d/%y')\n \"#{self.start_time.in_time_zone(self.school.timezone).strftime('%A')}</br>#{self.start_time.in_time_zone(self.school.timezone).strftime('%-m/%d/%y')}\".html_safe()\n end",
"def formatted_datetime(date_time)\n date_time.strftime(\"%a, %e %b %Y %H:%M\")\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def fmt_time(dt) _format_dt dt, H12_M_PM end",
"def pretty_hours(locale=I18n.locale)\n if starts_at.to_date.eql?(ends_at.to_date)\n # Same day, different hours\n \"#{starts_at.strftime('%H:%M')} - #{ends_at.strftime('%H:%M')}\" \n else\n # Different dates\n start_date = starts_at.strftime('%H%M') == \"0000\" ? I18n.localize(starts_at.to_date, :format => :long, :locale => locale) : I18n.localize(starts_at, :format => :long, :locale => locale)\n end_date = ends_at.strftime('%H%M') == \"0000\" ? I18n.localize(ends_at.to_date, :format => :long, :locale => locale) : I18n.localize(ends_at, :format => :long, :locale => locale)\n \"#{start_date} - #{end_date}\"\n end \n end",
"def to_s\n s = @display.strftime(time_format)\n case @display_granularity\n when :ten_minute\n s.chop!\n s << \"~\"\n when :one_hour\n s.chop!\n s.chop!\n s << \"~~\"\n end\n return s\n end",
"def utc_day_str\n self.datetime.strftime(\"%A\")\n end",
"def gnupg_date_format(maybe_datetime)\n datetime = case maybe_datetime\n when DateTime then maybe_datetime\n when Time, Date then maybe_datetime.to_datetime\n else raise ArgumentError,\n \"datetime: has to be a DateTime/Time/Date\"\n end\n\n # datetime.utc.iso8601.gsub(/-|:/, '')[0..-6]\n datetime.utc.iso8601.gsub(/-|:/, \"\")[0..-6]\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def friendly_created_at\n created_at.strftime(\"%m-%e-%y %H:%M\")\n end",
"def format_date(date)\n am_or_pm = date.slice -2..-1\n less_stamp = date.slice(0..7)\n hour = date.slice 0..1\n hour = hour.to_i\n if am_or_pm == \"AM\"\n if hour == 12 # subtract 12\n hour = \"00\"\n puts hour << date.slice(2..7)\n else\n puts date.slice(0..7)\n end\n else\n if hour != 12\n hour = hour + 12\n hour = hour.to_s\n puts hour << date.slice(2..7)\n else\n hour = hour + 1\n hour = hour.to_s\n puts hour << date.slice(2..7)\n end\n end\nend",
"def date_time_str(time)\n \"#{time.utc.strftime('%Y-%m-%d')}T#{time.utc.strftime('%H:%M:%S.%L')}Z\"\n end",
"def formatted_date\n \tobject.created_at.strftime(\"%R - %B %e, %Y \")\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def format_date_and_time(date)\n date.day == Time.zone.now.day ? date.to_s(:time) : date_and_time_formatter(date)\n end",
"def _format_date(date)\n return unless date\n\n DateTime.parse(date.to_s).iso8601\n end",
"def formatted_date_time\n self.current_state.formatted_date_time\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def to_s\n @date_time\n end",
"def date_format tim\n # tim.strftime '%Y/%m/%d %H:%M:%S'\n tim.strftime '%Y/%m/%d %H:%M'\nend",
"def format_date_time(date_time)\n if defined?(ActiveSupport)\n date_time.strftime(DATE_TIME_FORMAT)\n else\n date_time.inspect\n end\n end",
"def inspect\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{period.abbreviation}\"\n end",
"def pickup_date_print(request)\n request.pickup_time.strftime(\"%A %d-%m-%Y %H:%M\")\n end",
"def format_date_time( dt )\n dt.strftime( \"%B %e, %Y %I:%M%p\" )\nend",
"def hour_12\n self.strftime(\"%I:%M %p\")\n end",
"def hour_12\n self.strftime(\"%I:%M %p\")\n end",
"def time\n if created_at.try(:to_date) == Date.today\n created_at.strftime('%H:%M%P')\n else\n created_at.try(:strftime, '%d-%m-%Y')\n\n end\n end",
"def to_s\n dte = self.date.strftime('%b %d %I:%M %P')\n des = self.description\n loc = self.location\n \"#{dte} #{des} #{loc}\"\n end",
"def to_s\n s = (to_s_pieces(DATE_FIELDS) + [to_s_time_piece]).compact.join(' ')\n if s == \"\"\n \"0 days\"\n else\n s\n end + (ago ? \" ago\" : \"\")\n end",
"def date_str d\n Util::date(d)\n end",
"def nice_date(date, user)\n zone = (user && user.time_zone) ? user.time_zone : ActiveSupport::TimeZone.new(\"GMT\")\n timezoned = date.in_time_zone(zone)\n res = format_time(timezoned)\n (user && user.time_zone) ? res : (res + \" GMT\")\n end",
"def get_yyyymmdd_hhnnss(s)\n return s.gsub('T', ' ').gsub('Z', '')\n end",
"def iso8601\n utc.strftime DATE_FORMATS[:iso8601]\n end",
"def date_time\n created_at.strftime('%-m/%-d/%Y %-I:%M %P')\n end",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def display_time_for_appointment\n date.strftime(\"%I:%M:%S %p, %B #{date.day.ordinalize}, %Y\")\n end",
"def decorated_updated_at\n updated_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def to_s\n if @am_pm\n display = @current.strftime(\"%I:%M\")\n else\n display = @current.strftime(\"%H:%M\")\n end\n @fuzz.times { display.sub!(/\\d(\\D*)$/, '~\\1') } if @fuzz > 0\n display\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def httpdate\n return \"#{self.day_name[0, 3]}, #{@t_day} #{self.month_name[0, 3]} #{@t_year} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec} GMT\"\n end",
"def GetCurrentFormattedTimeForDiagLogs()\n Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S.%6NZ\")\n end",
"def GetCurrentFormattedTimeForDiagLogs()\n Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S.%6NZ\")\n end",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def scanned_at_human_time\n format = object.scanned_at.today? ? '%H:%M' : '%d/%m %H:%M'\n\n I18n.l card_scan.scanned_at, format: format\n end",
"def date\n \"#{self[:day]}_#{self[:month]}_#{self[:year]}\"\n end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end"
] |
[
"0.68358004",
"0.6781176",
"0.6676465",
"0.6548966",
"0.6546911",
"0.6520813",
"0.651328",
"0.648706",
"0.6472163",
"0.6292472",
"0.62876934",
"0.62299997",
"0.62299997",
"0.6177343",
"0.61736315",
"0.61465746",
"0.6122212",
"0.6104503",
"0.6080567",
"0.6074086",
"0.60721505",
"0.60462314",
"0.6040613",
"0.6035141",
"0.6031963",
"0.60274243",
"0.5984741",
"0.59651226",
"0.5952409",
"0.59510726",
"0.5946108",
"0.5940555",
"0.5940555",
"0.59404415",
"0.5902506",
"0.58893037",
"0.58864653",
"0.5874688",
"0.58730525",
"0.5872027",
"0.5861759",
"0.58497906",
"0.5848048",
"0.58398014",
"0.58391607",
"0.5838266",
"0.5829716",
"0.5826161",
"0.5823409",
"0.58151466",
"0.581125",
"0.5803999",
"0.57968676",
"0.5786967",
"0.57831144",
"0.5777946",
"0.57704836",
"0.57633513",
"0.576333",
"0.5762134",
"0.57591677",
"0.57572216",
"0.5752261",
"0.5748863",
"0.57474226",
"0.57462096",
"0.5745941",
"0.5745941",
"0.57421434",
"0.57327557",
"0.57309043",
"0.57247394",
"0.5715999",
"0.5699718",
"0.56957555",
"0.5693825",
"0.5693825",
"0.56911516",
"0.56718755",
"0.56715524",
"0.56691897",
"0.5652681",
"0.56489235",
"0.564839",
"0.5638034",
"0.56255466",
"0.56208646",
"0.56188583",
"0.56171453",
"0.56146914",
"0.56142604",
"0.5608824",
"0.56072897",
"0.56072897",
"0.56023216",
"0.5601737",
"0.55979586",
"0.5596078",
"0.558792",
"0.5580596"
] |
0.6031681
|
25
|
Formats a CarbonDate::Date with minute precision as a string Returns: A humanreadable string representing the Date
|
def minute(date)
time = [pad(date.hour.to_s), pad(date.minute.to_s)].join(':')
[time, day(date)].join(' ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def start_time_string\n date_component = self.start_time.strftime(\"%b %-d\")\n time_component = self.start_time.strftime(\"%-l:%M%P %Z(%:z)\")\n\n \"#{date_component} at #{time_component}\"\n end",
"def min_to_formatted_time(mnt)\n\t\t(Time.now.midnight + mnt.minutes).to_s(:hr12)\n\tend",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def formatted_date datetime\n return '' if datetime.nil?\n\n datetime.strftime '%Y-%m-%d %H:%m'\n end",
"def date_formate(date)\n return nil if date.blank?\n date.strftime('%m/%d/%Y %I:%M %p')\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def to_s\n \"#{hour.to_s.rjust(2, '0')}:#{minute.to_s.rjust(2, '0')}\"\n end",
"def format_date_nicely(date)\nend",
"def to_s\n format('%<hours>02dh%<minutes>02dm', hours: @hours, minutes: @minutes)\n end",
"def decorated_created_at\n created_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def show_in_strftime\n @date.strftime(\"%d/%m/%Y -- %H:%M\")\n end",
"def to_s_for_cap\n to_datetime.to_s_for_cap\n end",
"def date_str(date)\n date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')\nend",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def date(options = {})\n res = \"\"\n res += \"#{I18n.localize(self.starts_at, :format => '%A %d')} de \" if options[:include_week_day] != false\n res += \"#{I18n.localize(self.starts_at, :format => '%B')} de \" if options[:include_month] != false\n # TODO: hack hack hack 20 min\n res += \"#{self.starts_at.strftime(\"%H:%M\")} a #{self.ends_at.strftime(\"%H:%M\")}\"\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def format(precise: false)\n return '-' if @ms.nil?\n\n return Kernel.format('%02d:%02d:%02d.%03d', hours, minutes, seconds, milliseconds) if precise\n Kernel.format('%02d:%02d:%02d', hours, minutes, seconds)\n end",
"def human_datetime_minute_mask\n case session[:database][:locale]\n when \"de\" then \"TT.MM.JJJJ HH:MI\"\n when \"en\" then \"YYYY-MM-DD HH:MI\"\n else \"TT.MM.JJJJ HH24:MI\" # Deutsche Variante als default\n end\n end",
"def formatted_created_at\n self.created_at.to_date.to_s(:long)\nend",
"def humanized_minute(minutes)\n if minutes == 1\n ' ' << t('plugin_spent_time_in_issue.datetime.minutes.one')\n elsif minutes > 1\n ' ' << t('plugin_spent_time_in_issue.datetime.minutes.other', minutes: minutes)\n else\n ''\n end\n end",
"def pretty_time\n t = self.start_time\n t.strftime(\"%a, %b %e, %l:%M %p\")\n end",
"def detail_date( date )\n date.strftime( '%H:%M - %b %d, %Y')\n end",
"def to_s\n s = @display.strftime(time_format)\n case @display_granularity\n when :ten_minute\n s.chop!\n s << \"~\"\n when :one_hour\n s.chop!\n s.chop!\n s << \"~~\"\n end\n return s\n end",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def day_month_year_hour_minute\n I18n.locale.to_s == 'pt' ? \"%d/%m/%Y %H:%M\" : \"%m/%d/%Y %I:%M %P\"\n end",
"def short_time\n \ttime.strftime \"%b %-d\"\n end",
"def formatted_date_time\n self.current_state.formatted_date_time\n end",
"def format_minute(minute)\n first, second = minute.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0],\n first_digit_arr[1] + second_digit_arr[1],\n first_digit_arr[2] + second_digit_arr[2]\n ]\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def formatted_creation_date\n self.created_at.strftime(\"%b %d '%y %H:%M\")\n end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def format_date(date)\n year, month, day, day_name, hour = [\n date.year,\n Date::MONTHNAMES[date.month],\n date.day.ordinalize,\n date.strftime(\"%A\"),\n convert_hour(date.hour, 'standard')\n ]\n\n \"#{day_name} #{month} #{day}, #{year} at #{hour}\"\n end",
"def decorated_updated_at\n updated_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def pretty_runtime\n return nil if total_time.nil?\n t = total_time / 1000\n minutes = t / 60\n seconds = t - 60 * minutes\n sprintf '%d:%02d', minutes, seconds\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def minute\n self.to_duration.to_units(:hour, :minute, :second).fetch(:minute)\n end",
"def to_s\n '%02d:%02d' % [(@hours % 24), @minutes]\n end",
"def format\n puts \"-\" * 60\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def to_s\n @date_time\n end",
"def round( date )\n return date\n end",
"def minute_timestamp_from_producer_clock\n t=Time.now\n t.strftime(\"%Y%j%H%M\").to_i\n end",
"def formatted_date_time date, time\n date_time = merge_date_time date, time\n I18n.localize date_time\n end",
"def get_formatted_timestamp()\n return Time.now.iso8601.to_s\n end",
"def start_date_as_string\n as_string @start_date\n end",
"def scanned_at_human_time\n format = object.scanned_at.today? ? '%H:%M' : '%d/%m %H:%M'\n\n I18n.l card_scan.scanned_at, format: format\n end",
"def get_formatted_hour\n start_on.strftime(\"%H:%M\")\n end",
"def date_format tim\n # tim.strftime '%Y/%m/%d %H:%M:%S'\n tim.strftime '%Y/%m/%d %H:%M'\nend",
"def date_format(date, options={})\n format = options[:format] || :long\n# puts 'date_format on ' + date.class.name + \" --- \" + date.inspect\n user ||= @current_user\n return '' if date.nil?\n date = Time.parse(date) if date.is_a?(String)\n if date.is_a?(Date) && !date.is_a?(DateTime) && !date.is_a?(Time)\n return date.to_formatted_s(format)\n end\n return date.to_local_s(user, :format=>format)\n end",
"def date\n moment.floor\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def time_of_day(minute)\n minute = minute % 1440\n minute += 1440 if minute < 0\n \"%02d:%02d\" %[minute/60, minute%60]\nend",
"def minute(padded = false)\n min = (seconds_since_start_of_hour / M_SECS).to_i\n if padded && min < 10\n min = \"0#{min}\"\n end\n min\n end",
"def nice_date(date, ofset=1)\n if date\n format = (!session or session[:date_format].to_s.blank?) ? \"%Y-%m-%d\" : session[:date_format].to_s\n t = date.respond_to?(:strftime) ? date : date.to_time\n t = t.class.to_s == 'Date' ? t.to_time : t\n d = (session and ofset.to_i == 1) ? current_user.user_time(t).strftime(format.to_s) : t.strftime(format.to_s)\n else\n d=''\n end\n return d\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def formatted_duration\n hours = self.duration / 60\n minutes = self.duration % 60\n if minutes == 0\n \"#{hours}h\"\n else\n \"#{hours}h#{minutes}min\"\n end\n end",
"def date_time\n created_at.strftime('%-m/%-d/%Y %-I:%M %P')\n end",
"def get_date\n format_date DateTime.new(2011, 1, 1, 17, 9, 59)\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def to_s()\n\t\tself.to_chrono()\n\tend",
"def fmt_miltime(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.time_fmt)\n end\n end",
"def mins\n Thread.current[:datet_mode] = :mins\n return self\n end",
"def as_datetime_in_words\n strftime \"%b %d %I:%M %p\"\n end",
"def start_time_to_s\n\t \tself.start_date.try(:strftime, '%H:%M:%S')\n\t end",
"def formatted_short_start_time(time_zone='Pacific Time (US & Canada)')\n Time.parse(run.start_time.to_s).in_time_zone(time_zone).strftime('%a, %-m/%-d/%Y %l:%M%P')\n end",
"def decorated_created_at\n\t created_at.to_date.to_s( :long )\n\t end",
"def formatted_date\n \tobject.created_at.strftime(\"%R - %B %e, %Y \")\n end",
"def formated_date( input, format=$date_format )\n if not format.nil? and not input.nil?\n res = ParseDate.parsedate( input )\n Time.local(*res).strftime( format )\n else\n input\n end\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def to_s\n if @am_pm\n display = @current.strftime(\"%I:%M\")\n else\n display = @current.strftime(\"%H:%M\")\n end\n @fuzz.times { display.sub!(/\\d(\\D*)$/, '~\\1') } if @fuzz > 0\n display\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def now_str() _format_dt DateTime.now, DT_TM end",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def get_time_placed\n self.created_at.strftime(\"%m/%d/%Y at %l:%M%p\")\n end",
"def to_s\n\t\ts, m = @sec % 60, @sec / 60\n\t\th = m / 60\n\t\tm = m % 60\n\t\treturn (\"%02d:%02d:%02d\" % [h, m, s])\n\tend",
"def format_date_time(date_time)\n if defined?(ActiveSupport)\n date_time.strftime(DATE_TIME_FORMAT)\n else\n date_time.inspect\n end\n end",
"def to_short_datetime\n self.strftime(\"%Y/%m/%d\") \n end",
"def to_s\n if year == 0 and mon == 0 and day == 0\n h = neg ? hour * -1 : hour\n sprintf \"%02d:%02d:%02d\", h, min, sec\n else\n sprintf \"%04d-%02d-%02d %02d:%02d:%02d\", year, mon, day, hour, min, sec\n end\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def format_date_time( dt )\n dt.strftime( \"%B %e, %Y %I:%M%p\" )\nend",
"def to_string(t)\n t.respond_to?(:getutc) ? t.getutc.strftime(DATE_FORMAT) : t.strftime(DATE_FORMAT)\n end",
"def j; cat @time.strftime('%j') end",
"def formatted_timestamp(date)\n Date.parse(date).strftime('%d/%m/%Y')\n end",
"def get_duration\n return \"#{self.duration.to_s.sub!('.', ',')} #{I18n.t(\"labels.datetime.hour_short\")}\"\n end",
"def started_at_date\n if !@started_at_date_string\n @started_at_date_string = self.start_date_time.strftime(\"%A %-m/%d/%Y\")\n end\n @started_at_date_string\n end",
"def tt(time, format=:short); '13:37'; end",
"def formatted_time\n start_time = \"#{self.start_time.strftime(\"%l:%M\")} #{self.start_time.strftime(\"%p\")}\"\n end_time = \"#{self.end_time.strftime(\"%l:%M\")} #{self.end_time.strftime(\"%p\")}\"\n \"#{start_time} - #{end_time}\"\n end",
"def _format_date(date)\n return unless date\n\n DateTime.parse(date.to_s).iso8601\n end"
] |
[
"0.65942013",
"0.61959046",
"0.59428924",
"0.59124947",
"0.5905701",
"0.5872843",
"0.5849906",
"0.5840041",
"0.58203125",
"0.5809602",
"0.57933164",
"0.57621205",
"0.57257676",
"0.57216126",
"0.5713124",
"0.5702826",
"0.56995213",
"0.5685221",
"0.5661887",
"0.56459457",
"0.56459457",
"0.56364864",
"0.56325954",
"0.5630598",
"0.5630182",
"0.5625657",
"0.5623508",
"0.55926067",
"0.55774087",
"0.5576415",
"0.5573713",
"0.5571768",
"0.557128",
"0.5561117",
"0.55131215",
"0.55091953",
"0.5505537",
"0.5499904",
"0.5499013",
"0.54903466",
"0.54870796",
"0.54856545",
"0.54753584",
"0.54659194",
"0.54651123",
"0.5456919",
"0.5449049",
"0.5442451",
"0.5439846",
"0.5431956",
"0.5423725",
"0.54114956",
"0.5389082",
"0.5385817",
"0.53630877",
"0.53594524",
"0.53591573",
"0.5351221",
"0.5349888",
"0.5349561",
"0.5343819",
"0.5336225",
"0.5334651",
"0.53319985",
"0.53296494",
"0.532786",
"0.53259856",
"0.53254133",
"0.532145",
"0.5317247",
"0.5311633",
"0.5303432",
"0.53032255",
"0.5298088",
"0.52976453",
"0.52961445",
"0.52961445",
"0.5292612",
"0.5279753",
"0.527887",
"0.527887",
"0.52782077",
"0.52727306",
"0.525975",
"0.52585936",
"0.5257164",
"0.5255674",
"0.5254836",
"0.52548325",
"0.5245801",
"0.5245801",
"0.52402294",
"0.5233961",
"0.52338845",
"0.52335024",
"0.5228407",
"0.522222",
"0.521982",
"0.5218519",
"0.5217344"
] |
0.63774943
|
1
|
Formats a CarbonDate::Date with second precision as a string Returns: A humanreadable string representing the Date
|
def second(date)
time = [pad(date.hour.to_s), pad(date.minute.to_s), pad(date.second.to_s)].join(':')
[time, day(date)].join(' ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def format_date_nicely(date)\nend",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def to_s_for_cap\n to_datetime.to_s_for_cap\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def format(precise: false)\n return '-' if @ms.nil?\n\n return Kernel.format('%02d:%02d:%02d.%03d', hours, minutes, seconds, milliseconds) if precise\n Kernel.format('%02d:%02d:%02d', hours, minutes, seconds)\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def to_s\n second_format = (second % 1).zero? ? '%02d' : '%04.1f'\n\n format(\"%04d-%02d-%02dT%02d:%02d:#{second_format}%s\", *atoms)\n end",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def db_formatted_d( d )\n# d.try( :to_formatted_s, :db_date )\n d&.to_formatted_s( :db_date )\n end",
"def to_date string\n \n end",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def to_s\n \"#{@date.to_s}: #{@text}\"\n end",
"def formatted_date\n \"#{self.day.date.strftime(\"%A, %B %e, %Y\")}\"\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def date_str d\n Util::date(d)\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def formatted_created_at\n self.created_at.to_date.to_s(:long)\nend",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def formatted_timestamp(date)\n Date.parse(date).strftime('%d/%m/%Y')\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def to_s(pretty=true)\n d, h, m, s, ms = elapsed\n e_t = (d > 0) ? \"#{d.to_s}d \" : ''\n if pretty\n e_t += ('%02u:' % [h]) if (d + h) > 0\n e_t += ('%02u:' % [m]) if (d + h + m) > 0\n e_t += '%02u.%03u' % [s, ms]\n else\n e_t << '%02u:%02u:%02u.%03u' % [h,m,s, ms]\n end\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def quoted_date(value) #:nodoc:\n if value.acts_like?(:time) && value.respond_to?(:usec)\n \"#{super}.#{sprintf(\"%06d\", value.usec)}\"\n else\n super\n end\n end",
"def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end",
"def detail_date( date )\n date.strftime( '%H:%M - %b %d, %Y')\n end",
"def decorated_created_at\n created_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def to_s\n s = (to_s_pieces(DATE_FIELDS) + [to_s_time_piece]).compact.join(' ')\n if s == \"\"\n \"0 days\"\n else\n s\n end + (ago ? \" ago\" : \"\")\n end",
"def format_timestamp(t)\n t.strftime('%s%9N')\n end",
"def format_date(str)\n str.sub(/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/, '\\3.\\2.\\1')\nend",
"def decorated_updated_at\n updated_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def date_to_s\n self.date.strftime(\"%B %d, %Y\")\n end",
"def date_str(date)\n date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')\nend",
"def get_formatted_timestamp()\n return Time.now.iso8601.to_s\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def to_s\n @date\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def quoted_date(value)\n if value.acts_like?(:time)\n if value.respond_to?(:getutc)\n value = value.getutc\n end\n end\n\n result = value.to_s(:db)\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def date_formatter(date)\n date_array = date.split(\":\")\n\n # Clean up formatting\n date_array.first.gsub!(\"T\", \" \")\n date_array.last.delete!(\"Z\")\n return_date = date_array.join(\":\")\n\n return_date << \" (UTC+0:00)\"\n end",
"def to_s\n sub_sec = @nano_seconds.to_f / (10**9)\n sub_sec_str = sub_sec.to_s.gsub('0.', '')\n \"#{@hours}:#{@minutes}:#{@seconds}.#{sub_sec_str}\"\n end",
"def round( date )\n return date\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def format_date_to_s(val)\n Date.parse(val.to_s).strftime('%m/%d/%Y')\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def format_date(string)\n string.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)/, '\\3.\\2.\\1')\nend",
"def to_s\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{formatted_offset(false, 'UTC')}\" # mimicking Ruby Time#to_s format\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def to_s\n \"#{start_date_as_string}-#{end_date_as_string}\"\n end",
"def format_date2(date)\n date.gsub(/\\A(\\d{4})([\\-\\/])(\\d\\d)([\\-\\/])(\\d\\d)\\z/, '\\5.\\3.\\1')\nend",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def format_date(string)\n string.sub(/\\A(\\d{4})-(\\d{2})-(\\d{2})\\z/, '\\3.\\2.\\1')\nend",
"def decorated_created_at\n\t created_at.to_date.to_s( :long )\n\t end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def nice_date(date, ofset=1)\n if date\n format = (!session or session[:date_format].to_s.blank?) ? \"%Y-%m-%d\" : session[:date_format].to_s\n t = date.respond_to?(:strftime) ? date : date.to_time\n t = t.class.to_s == 'Date' ? t.to_time : t\n d = (session and ofset.to_i == 1) ? current_user.user_time(t).strftime(format.to_s) : t.strftime(format.to_s)\n else\n d=''\n end\n return d\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def format_date(string)\n string.sub(/\\A(\\d{4})([\\-\\/])(\\d{2})\\2(\\d{2})\\z/, '\\4.\\3.\\1')\nend",
"def to_s\n @date_time\n end",
"def to_string(t)\n t.respond_to?(:getutc) ? t.getutc.strftime(DATE_FORMAT) : t.strftime(DATE_FORMAT)\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def pretty_date(date)\n if date.today?\n return t(:today)\n elsif date.to_date == Date.yesterday\n return t(:yesterday)\n else\n return date.strftime(\"%b %d, %Y\")\n end\n end",
"def format_date(date)\n year, month, day, day_name, hour = [\n date.year,\n Date::MONTHNAMES[date.month],\n date.day.ordinalize,\n date.strftime(\"%A\"),\n convert_hour(date.hour, 'standard')\n ]\n\n \"#{day_name} #{month} #{day}, #{year} at #{hour}\"\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def human_date(date, optional_text= nil)\n if optional_text\n date.strftime(\"#{optional_text}\"+\" %d.%m.%Y\")\n else\n date.strftime(\"%d.%m.%Y\")\n end\n end",
"def date_format(date, options={})\n format = options[:format] || :long\n# puts 'date_format on ' + date.class.name + \" --- \" + date.inspect\n user ||= @current_user\n return '' if date.nil?\n date = Time.parse(date) if date.is_a?(String)\n if date.is_a?(Date) && !date.is_a?(DateTime) && !date.is_a?(Time)\n return date.to_formatted_s(format)\n end\n return date.to_local_s(user, :format=>format)\n end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def to_s\n format = \n if @_utc then\n \"%a %b %d %H:%M:%S UTC %Y\"\n else\n \"%a %b %d %H:%M:%S %Z %Y\"\n end\n return LIBC.new.c_strftime(format, @vals)\n end",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def nice_time\n Time.at(time).utc.strftime('%-M:%Ss')\n end",
"def to_s()\n\t\tself.to_chrono()\n\tend"
] |
[
"0.6484579",
"0.6476181",
"0.6469141",
"0.646061",
"0.62972987",
"0.62581277",
"0.62081",
"0.6193074",
"0.615616",
"0.6139488",
"0.6139488",
"0.6138897",
"0.6071379",
"0.5993085",
"0.5993085",
"0.59857273",
"0.59679365",
"0.5956938",
"0.595501",
"0.5930252",
"0.59277177",
"0.59274715",
"0.59262896",
"0.5922832",
"0.5922832",
"0.5922032",
"0.5912021",
"0.59102154",
"0.59102154",
"0.59102154",
"0.59100085",
"0.5901538",
"0.5880265",
"0.5880231",
"0.5864811",
"0.5863481",
"0.5848407",
"0.58356136",
"0.5834601",
"0.58284676",
"0.58211356",
"0.58107406",
"0.58050644",
"0.57990485",
"0.5775815",
"0.57660127",
"0.5765208",
"0.5754868",
"0.57418334",
"0.57403123",
"0.5735212",
"0.5733304",
"0.57324",
"0.56843746",
"0.5681536",
"0.5681536",
"0.5681251",
"0.5658982",
"0.5658982",
"0.5655658",
"0.565488",
"0.565149",
"0.5643008",
"0.56361234",
"0.5634806",
"0.5630409",
"0.5629632",
"0.56284887",
"0.5626612",
"0.56153643",
"0.56133443",
"0.5612565",
"0.56089455",
"0.56080157",
"0.56054956",
"0.56049716",
"0.5601268",
"0.56009233",
"0.5599116",
"0.5591804",
"0.55905074",
"0.5581654",
"0.557718",
"0.55758893",
"0.557331",
"0.5569948",
"0.55687696",
"0.5564709",
"0.55599624",
"0.55542254",
"0.555398",
"0.55535257",
"0.5547908",
"0.5539551",
"0.5536037",
"0.552847",
"0.55274224",
"0.5527178",
"0.55243254",
"0.55208844"
] |
0.60055274
|
13
|
Formats a CarbonDate::Date with decade precision Returns: A humanreadable string representing the Date
|
def decade(date)
d = ((date.year.abs.to_i / 10) * 10).to_s + 's'
return [d, BCE_SUFFIX].join(' ') if (date.year <= -1)
d
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def format_date_nicely(date)\nend",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def to_date string\n \n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def date_str d\n Util::date(d)\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date(date)\n year, month, day, day_name, hour = [\n date.year,\n Date::MONTHNAMES[date.month],\n date.day.ordinalize,\n date.strftime(\"%A\"),\n convert_hour(date.hour, 'standard')\n ]\n\n \"#{day_name} #{month} #{day}, #{year} at #{hour}\"\n end",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def format_date( date = Date.today )\n date.strftime('%a %d/%m/%Y')\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def db_formatted_d( d )\n# d.try( :to_formatted_s, :db_date )\n d&.to_formatted_s( :db_date )\n end",
"def formatted_date\n \"#{self.day.date.strftime(\"%A, %B %e, %Y\")}\"\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def fmt_date(date)\n if (date)\n date.strftime(\"%m-%d-%Y\")\n end\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def dmy_date(date)\n Time.gm(date.year, date.month, date.day)\n end",
"def formatted_date(date)\n DateTime.parse(date).strftime('%-m/%-d/%y')\n rescue\n ''\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def easy_date; date; end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def date_to_s\n self.date.strftime(\"%B %d, %Y\")\n end",
"def geek_date(date)\n date.strftime(\"%Y-%m-%d\") \n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def formatFullDate(date)\n date.strftime(\"%A, %B %d, %Y\")\n end",
"def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end",
"def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end",
"def date\n \"#{day} #{month.capitalize} #{year}\"\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def human_date(date, optional_text= nil)\n if optional_text\n date.strftime(\"#{optional_text}\"+\" %d.%m.%Y\")\n else\n date.strftime(\"%d.%m.%Y\")\n end\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def formated_release_date_for(game)\n return \"\" if game.nil?\n formated_date(game.date)\n end",
"def to_s\n \"FiscalYear #{ year }: #{ fd(days.first) } to #{ fd(days.last) }\"\n end",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(date, format = \"%m/%d/%Y\")\n date.respond_to?(:strftime) ? date.strftime(format) : date.to_s\n end",
"def format_date2(date)\n date.gsub(/\\A(\\d{4})([\\-\\/])(\\d\\d)([\\-\\/])(\\d\\d)\\z/, '\\5.\\3.\\1')\nend",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def born_date\n super.to_s(:long)\n end",
"def str_dod\r\n\t\tunless self.date_of_death.nil?\r\n\t\t\tself.date_of_death.strftime(\"%v\")\r\n\t\tend\r\n\tend",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def date_short(date)\n\t\tdate.strftime(\"%b %e, %Y\") if !date.blank?\n\tend",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def format_human_readable_date(date)\n case date.to_date\n when Time.zone.today.to_date\n 'Today'\n when Time.zone.tomorrow\n 'Tomorrow'\n when Time.zone.yesterday\n 'Yesterday'\n else\n l(date, format: :short)\n end\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def date_format(date)\n\t if date\n\t date.strftime(\"%d/%m/%Y\")\n\t end\n\tend",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def pretty_embargo_date\n sul_pretty_date(@purl_object.embargo_release_date)\n end",
"def date\n dreport.date_format\n end",
"def format_date(date)\n return date unless !!date.match(/[\\-]+/)\n date.split(/\\-/).reverse.join(\".\")\nend",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def formatted_date(date)\n date.present? ? date.strftime(\"%A, %B %d, %Y\") : \"\"\n end",
"def to_s\n @date\n end",
"def date_dashes(d)\n d && d.length == 8 ? d.slice(0, 4) + \"-\" + d.slice(4, 2) + \"-\" + d.slice(6, 2) : d\n end",
"def date_formatter(date)\n date_array = date.split(\":\")\n\n # Clean up formatting\n date_array.first.gsub!(\"T\", \" \")\n date_array.last.delete!(\"Z\")\n return_date = date_array.join(\":\")\n\n return_date << \" (UTC+0:00)\"\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def format_date(date, format)\n date = datetime(date)\n if format.nil? || format.empty? || format == \"ordinal\"\n date_formatted = ordinalize(date)\n else\n format.gsub!(/%a/, ABBR_DAYNAMES_DE[date.wday])\n format.gsub!(/%A/, DAYNAMES_DE[date.wday])\n format.gsub!(/%b/, ABBR_MONTHNAMES_DE[date.mon])\n format.gsub!(/%B/, MONTHNAMES_DE[date.mon])\n date_formatted = date.strftime(format)\n end\n date_formatted\n end",
"def readable_date\n date.strftime(\"%B %d, %Y\")\n end",
"def quoted_date(value)\n if value.acts_like?(:time)\n if value.respond_to?(:getutc)\n value = value.getutc\n end\n end\n\n result = value.to_s(:db)\n end",
"def to_s\n s = (to_s_pieces(DATE_FIELDS) + [to_s_time_piece]).compact.join(' ')\n if s == \"\"\n \"0 days\"\n else\n s\n end + (ago ? \" ago\" : \"\")\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def normalize_fuzzy_date(date_str)\n if date_str.present?\n date_str = date_str.gsub(\"-\", \"\")\n if date_str.length < 8\n pad = 8 - date_str.length\n date_str += \"0\" * pad\n end\n end\n date_str\n end",
"def as_readable_date\n strftime \"%b %e, %Y\"\n end"
] |
[
"0.67224425",
"0.6532047",
"0.64644957",
"0.64226294",
"0.63994473",
"0.6208132",
"0.61918914",
"0.6159244",
"0.6159244",
"0.6119847",
"0.6119847",
"0.6119847",
"0.6091613",
"0.607432",
"0.60601646",
"0.60582453",
"0.6048835",
"0.60484886",
"0.6047693",
"0.6029764",
"0.60229665",
"0.6008982",
"0.6004191",
"0.60028356",
"0.60028356",
"0.6000167",
"0.59986794",
"0.5993788",
"0.59891164",
"0.59838223",
"0.59838223",
"0.5983303",
"0.5979354",
"0.5976299",
"0.59701943",
"0.59580743",
"0.595329",
"0.5951061",
"0.5937108",
"0.5931253",
"0.5929836",
"0.5927785",
"0.5927027",
"0.5924525",
"0.5923213",
"0.5922",
"0.5910166",
"0.5903025",
"0.5903025",
"0.5900533",
"0.58968663",
"0.5879681",
"0.587927",
"0.58788866",
"0.587746",
"0.58758265",
"0.5868316",
"0.5856188",
"0.5828425",
"0.5817717",
"0.58159715",
"0.58120114",
"0.58069456",
"0.5787243",
"0.57773185",
"0.5772696",
"0.5769566",
"0.5766283",
"0.5752524",
"0.57486826",
"0.57485867",
"0.5748305",
"0.5746322",
"0.57460225",
"0.5738418",
"0.5734811",
"0.5732033",
"0.5728885",
"0.57257956",
"0.5725351",
"0.5717952",
"0.57169056",
"0.5712463",
"0.57122844",
"0.5710646",
"0.57105076",
"0.5710063",
"0.5706911",
"0.5696497",
"0.56943184",
"0.56889504",
"0.5679152",
"0.5677791",
"0.56762064",
"0.56668043",
"0.56667197",
"0.5666571",
"0.56619334",
"0.5652765",
"0.565138"
] |
0.6248774
|
5
|
Formats a CarbonDate::Date with century precision Returns: A humanreadable string representing the Date
|
def century(date)
c = ((date.year.abs.to_i / 100) + 1).ordinalize + ' century'
return [c, BCE_SUFFIX].join(' ') if (date.year <= -1)
c
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def display_str_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n return century_str_matches.to_s if century_str_matches\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n return \"#{($1.to_i + 1).ordinalize} century\"\n end\n end",
"def process_century_date(ng_date_element)\n my_ng_date_element = ng_date_element.clone\n my_ng_date_element.content = begin\n orig_date_str = ng_date_element.text.strip\n # note: not calling DateParsing.display_str_for_century directly because non-year text is lost\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP) if orig_date_str\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n new_century_str = \"#{(century_matches[3].to_i + 1).ordinalize} century\"\n my_ng_date_element.content = \"#{century_matches[1]}#{new_century_str}#{century_matches[4]}\"\n else\n my_ng_date_element.content\n end\n rescue\n my_ng_date_element.content\n end\n my_ng_date_element\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def format_date( date = Date.today )\n date.strftime('%a %d/%m/%Y')\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def century(year)\n century = (year.to_f / 100).ceil.to_s\n suffix(century)\nend",
"def format_date_nicely(date)\nend",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def century(year)\n num = (year - 1) / 100 + 1\n century = num.to_s + suffix(num)\nend",
"def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def century(year)\n century = year / 100 + 1\n century -= 1 if year % 100 == 0\n century.to_s + century_suffix(century)\nend",
"def century(year)\n century = year / 100 + 1\n century -= 1 if year % 100 == 0\n century.to_s + century_suffix(century)\nend",
"def century(year)\n century = year / 100 + 1\n century -= 1 if year % 100 == 0\n century.to_s + century_suffix(century)\nend",
"def century(year)\n century = year / 100 + 1\n century -= 1 if year % 100 == 0\n century.to_s + century_suffix(century)\nend",
"def century(year)\n century = year / 100 + 1\n century -= 1 if year % 100 == 0\n century.to_s + century_suffix(century)\nend",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def century(year)\n century = (year / 100) + 1\n century -= 1 if year % 100 == 0\n \n century.to_s + century_suffix(century)\nend",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def century(year)\n year % 100 == 0 ? cent = (year / 100).to_s : cent = (year / 100 + 1).to_s\n \n if cent[-1] == \"1\" && cent[-2] != \"1\"\n cent + \"st\"\n elsif cent[-1] == \"2\" && cent[-2] != \"1\"\n cent + \"nd\"\n elsif cent[-1] == \"3\" && cent[-2] != \"1\"\n cent + \"rd\"\n else\n cent + \"th\"\n end\nend",
"def sortable_year_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n return $1 + '00' if $1.length == 2\n return '0' + $1 + '00' if $1.length == 1\n end\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n if century_str_matches\n yy = ($1.to_i - 1).to_s\n return yy + '00' if yy.length == 2\n return '0' + yy + '00' if yy.length == 1\n end\n end",
"def century(year)\n if year % 100 == 0\n century = year / 100\n else\n century = (year / 100) + 1\n end\n\n century.to_s + century_suffix(century)\nend",
"def formatted_date(date)\n DateTime.parse(date).strftime('%-m/%-d/%y')\n rescue\n ''\n end",
"def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def geek_date(date)\n date.strftime(\"%Y-%m-%d\") \n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def format_date2(date)\n date.gsub(/\\A(\\d{4})([\\-\\/])(\\d\\d)([\\-\\/])(\\d\\d)\\z/, '\\5.\\3.\\1')\nend",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def century(year)\n century = (year / 100) + 1\n century -= 1 if year % 100 == 0\n return century.to_s + century_suffix(century)\nend",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def century(year)\n century = year / 100\n century += 1 if year % 100 != 0\n century.to_s + suffix(century)\nend",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def formatted_date\n \"#{self.day.date.strftime(\"%A, %B %e, %Y\")}\"\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def century(year)\n century = year / 100 if year % 100 == 0\n century = (year / 100) + 1 if year % 100 != 0\n \"#{century}#{ordinal(century)}\"\nend",
"def formatFullDate(date)\n date.strftime(\"%A, %B %d, %Y\")\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def century_year(year)\n\n\tcentury_year = year.div(100) + 1\n\tcentury_year -= 1 if year % 100 == 0\n\tcentury_year.to_s + century_suffix(century_year)\n\nend",
"def format_date(date)\n if date.nil?\n return \"\"\n end\n if date.year == Date.today.year\n return date.strftime(\"%A, %B %-d\") unless date.nil?\n else\n return date.strftime(\"%A, %B %-d %Y\") unless date.nil?\n end\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def century(year)\n century = year / 100\n remainder = year % 100\n \n remainder > 0 ? century += 1 : century\n \n \"#{century}\" + century_suffix(century)\nend",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def formatdate(date)\n p date.gsub(/^(\\d{4})([-\\/])(\\d{2})([-\\/])(\\d{2}$)/, '\\5.\\3.\\1') \nend",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date, format = \"%m/%d/%Y\")\n date.respond_to?(:strftime) ? date.strftime(format) : date.to_s\n end",
"def born_date\n super.to_s(:long)\n end",
"def century(year)\r\n cent = (year.to_f / 100).ceil.to_s\r\n\r\n if cent.end_with?(\"1\") && !(cent.end_with?(\"11\"))\r\n cent << \"st\"\r\n elsif cent.end_with?(\"2\") && !(cent.end_with?(\"12\"))\r\n cent << \"nd\"\r\n elsif cent.end_with?(\"3\") && !(cent.end_with?(\"13\"))\r\n cent << \"rd\"\r\n else\r\n cent << \"th\"\r\n end\r\nend",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def dncDate(dnc)\n if dnc.date == nil\n \"\"\n else\n dnc.date.strftime(\"%m/%d/%y\")\n end\n end",
"def to_date string\n \n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def date_to_s\n self.date.strftime(\"%B %d, %Y\")\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def century(year)\n result = year.divmod(100)\n century = result[0] + 1\n century -= 1 if year % 100 == 0\n century.to_s + century_suffix(century)\nend",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def fmt_date(date)\n if (date)\n date.strftime(\"%m-%d-%Y\")\n end\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def get_single_digit_century(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{1}th/)\n next if matches.empty?\n\n if matches.length == 1\n @pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'\n return @pub_year\n else\n # when there are multiple matches, check for ones with CE after them\n matches.each do |match|\n pos = f_date.index(Regexp.new(match + '...CE'))\n pos = pos ? pos.to_i : f_date.index(Regexp.new(match + ' century CE'))\n pos = pos ? pos.to_i : 0\n if f_date.include?(match + ' CE') || pos > 0\n @pub_year = (match[0, 1].to_i - 1).to_s + '--'\n return @pub_year\n end\n end\n end\n end\n nil\n end",
"def solrize_date(date)\n date.strftime('%Y-%m-%dT00:00:00Z')\n end",
"def date_format(date)\n\t if date\n\t date.strftime(\"%d/%m/%Y\")\n\t end\n\tend",
"def century(year)\n if year % 100 == 0\n c = year / 100\n else\n c = (year / 100) + 1\n end\n\n h = { 0 => 'th', 1 => 'st', 2 => 'nd', 3 => 'rd',\n 4 => 'th', 5 => 'th', 6 => 'th', 7 => 'th',\n 8 => 'th', 9 => 'th' }\n t = { 11 => 'th', 12 => 'th', 13 => 'th'}\n\n digit = c % 10\n if c == 11 || c == 12 || c == 13\n \"#{c}#{t[c]} century\"\n else\n \"#{c}#{h[digit]} century\"\n end\nend",
"def format_date(date_str)\n puts date_str.sub(/(\\d{4})([\\-\\/])(\\d{2})\\2(\\d{2})/, '\\4.\\3.\\1') \nend",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def formatted_date(date)\n date.present? ? date.strftime(\"%A, %B %d, %Y\") : \"\"\n end",
"def date_str d\n Util::date(d)\n end",
"def dateize(date)\n if not date.nil?\n date.strftime(\"%Y-%m-%d\")\n end\nend",
"def century(year)\n if year % 100 == 0\n century = (year / 100).to_s\n else\n century = (year / 100 + 1).to_s\n end\n \n if century[-2] == '1'\n century + 'th'\n elsif century[-1] == '1'\n century + 'st'\n elsif century[-1] == '2'\n century + 'nd'\n elsif century[-1] == '3'\n century + 'rd'\n else\n century + 'th'\n end\nend",
"def formatted_date(date = nil)\n return '' unless date\n date.last_modified_date.strftime(\"%m/%d/%y\")\n end",
"def get_double_digit_century(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{2}th/)\n next if matches.empty?\n\n if matches.length == 1\n @pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'\n return @pub_year\n else\n # when there are multiple matches, check for ones with CE after them\n matches.each do |match|\n pos = f_date.index(Regexp.new(match + '...CE'))\n pos = pos ? pos.to_i : f_date.index(Regexp.new(match + ' century CE'))\n pos = pos ? pos.to_i : 0\n if f_date.include?(match + ' CE') || pos > 0\n @pub_year = (match[0, 2].to_i - 1).to_s + '--'\n return @pub_year\n end\n end\n end\n end\n nil\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def to_century(**options) = convert_to('century', **options)",
"def format_date_to_s(val)\n Date.parse(val.to_s).strftime('%m/%d/%Y')\n end",
"def century(year)\n century = year / 100\n if year % 100 > 0\n century += 1\n end\n century = century.to_s\n if (century[-1] == \"1\") && (century[-2] != \"1\")\n century += 'st'\n elsif (century[-1] == \"2\") && (century[-2] != \"1\")\n century += 'nd'\n elsif (century[-1] == \"3\") && (century[-2] != \"1\")\n century += 'rd'\n else\n century += 'th'\n end\nend",
"def normalize_fuzzy_date(date_str)\n if date_str.present?\n date_str = date_str.gsub(\"-\", \"\")\n if date_str.length < 8\n pad = 8 - date_str.length\n date_str += \"0\" * pad\n end\n end\n date_str\n end",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def century(year)\n hundreds = ( (year + 99) / 100 ).to_s\n if hundreds[-2] == '1'\n suffix = 'th'\n else\n last_digit = hundreds[-1]\n case last_digit\n when '1' then suffix = 'st'\n when '2' then suffix = 'nd'\n when '3' then suffix = 'rd'\n else suffix = 'th'\n end\n end\n hundreds + suffix\nend",
"def format_date(string)\n string.sub(/\\A(\\d{4})([\\-\\/])(\\d{2})\\2(\\d{2})\\z/, '\\4.\\3.\\1')\nend",
"def translate_date\n (self.origin_date).strftime(\"%b %Y\")\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def to_fixed(fr_date = self)\n mmonth = fr_date.month\n dday = fr_date.day\n yyear = fr_date.year\n new_year = new_year_on_or_before((epoch + 180 + MEAN_TROPICAL_YEAR * (yyear - 1)).floor)\n new_year - 1 + 30 * (mmonth - 1) + dday\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def which_century(year)\n year.to_s[-1] == \"0\" ? (year / 100).to_s : (year / 100 + 1).to_s\nend",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def round( date )\n return date\n end"
] |
[
"0.6688998",
"0.6508177",
"0.63961935",
"0.63858837",
"0.63814676",
"0.63205165",
"0.63205165",
"0.6317557",
"0.6222274",
"0.62221074",
"0.62148434",
"0.6214128",
"0.6212795",
"0.6190952",
"0.6176208",
"0.6171632",
"0.614571",
"0.61113495",
"0.6083428",
"0.6071608",
"0.6070169",
"0.6070169",
"0.60595113",
"0.60595113",
"0.60595113",
"0.60595113",
"0.60595113",
"0.60459",
"0.6044624",
"0.6043711",
"0.60176814",
"0.59977365",
"0.5993928",
"0.5990174",
"0.59874797",
"0.59824836",
"0.59595543",
"0.5956019",
"0.595414",
"0.59321314",
"0.59089",
"0.5907466",
"0.59041613",
"0.5895749",
"0.5866414",
"0.5850628",
"0.58395064",
"0.5836369",
"0.58340085",
"0.58243966",
"0.58153015",
"0.5811009",
"0.5808171",
"0.580039",
"0.5799974",
"0.5792245",
"0.57798004",
"0.57767236",
"0.5764797",
"0.5764797",
"0.57534057",
"0.5748978",
"0.5740159",
"0.5726205",
"0.5719853",
"0.5700889",
"0.5700525",
"0.569975",
"0.5697377",
"0.5690759",
"0.5688417",
"0.56870854",
"0.5684287",
"0.567742",
"0.56769806",
"0.5666562",
"0.5665338",
"0.56642705",
"0.5661477",
"0.56516343",
"0.5643014",
"0.56414604",
"0.56380427",
"0.5635143",
"0.56306654",
"0.56301194",
"0.56301033",
"0.56189436",
"0.5618846",
"0.5615485",
"0.5613318",
"0.560895",
"0.5605439",
"0.560285",
"0.5602504",
"0.5594618",
"0.5593849",
"0.5583136",
"0.5577766",
"0.5573544"
] |
0.68591857
|
0
|
Formats a CarbonDate::Date with millennium precision Returns: A humanreadable string representing the Date
|
def millennium(date)
m = ((date.year.abs.to_i / 1000) + 1).ordinalize + ' millennium'
return [m, BCE_SUFFIX].join(' ') if (date.year <= -1)
m
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format_date_nicely(date)\nend",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def mdy(date)\n\t\t( date.nil? )?' ':date.strftime(\"%m/%d/%Y\")\n\tend",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def round( date )\n return date\n end",
"def dmy_date(date)\n Time.gm(date.year, date.month, date.day)\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def normalized_date\n text(data.at_xpath(\"#{data_root}/did/unitdate/@normal\"))\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def to_date string\n \n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end",
"def iso8601\n string = 'P'\n day = self.class.new 1, :day\n\n expand.each do |measured|\n string << 'T' if !string.include?('T') && measured < day\n string << measured.humanized_amount\n string << measured.unit.to_s[0, 1].capitalize\n end\n\n string\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def normalize_fuzzy_date(date_str)\n if date_str.present?\n date_str = date_str.gsub(\"-\", \"\")\n if date_str.length < 8\n pad = 8 - date_str.length\n date_str += \"0\" * pad\n end\n end\n date_str\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def format_date(date)\n return prefs.format_date(date)\n end",
"def born_date\n super.to_s(:long)\n end",
"def date\n moment.floor\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def to_fixed(j_date = self)\n mmonth = j_date.month\n dday = j_date.day\n yyear = j_date.year\n y = yyear < 0 ? yyear + 1 : yyear\n (epoch - 1 + (365 * (y - 1)) + quotient(y - 1, 4) + quotient(367 * mmonth - 362, 12) +\n (if mmonth <= 2\n 0\n elsif Julian::Year[yyear].leap_year?\n -1\n else\n -2\n end) +\n dday)\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def easy_date; date; end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def human_date(date, optional_text= nil)\n if optional_text\n date.strftime(\"#{optional_text}\"+\" %d.%m.%Y\")\n else\n date.strftime(\"%d.%m.%Y\")\n end\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def _format_date(date)\n return unless date\n\n DateTime.parse(date.to_s).iso8601\n end",
"def date_formate(date)\n return nil if date.blank?\n date.strftime('%m/%d/%Y %I:%M %p')\n end",
"def create_date_month_day\n\t\tcreated_at.to_date.to_formatted_s(:short)\n\tend",
"def date_short(date)\n\t\tdate.strftime(\"%b %e, %Y\") if !date.blank?\n\tend",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def format_date( date = Date.today )\n date.strftime('%a %d/%m/%Y')\n end",
"def formatted_created_at\n self.created_at.to_date.to_s(:long)\nend",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def formatted_date(date = nil)\n return '' unless date\n date.last_modified_date.strftime(\"%m/%d/%y\")\n end",
"def format_date(date)\n date.strftime(\"%Y-%m-%d\")\n end",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def fmt_date(date)\n if (date)\n date.strftime(\"%m-%d-%Y\")\n end\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def to_date()\n #This is a stub, used for indexing\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def to_s_for_cap\n to_datetime.to_s_for_cap\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_s\n self.date.strftime(\"%B %d, %Y\")\n end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def to_fixed(g_date = self)\n mmonth = g_date.month\n dday = g_date.day\n yyear = g_date.year\n ((epoch - 1) + \n (365 * (yyear - 1)) + \n quotient(yyear - 1, 4) - \n quotient(yyear - 1, 100) + \n quotient(yyear - 1, 400) + \n quotient((367 * mmonth) - 362, 12) +\n (if mmonth <= 2\n 0\n elsif leap_year?(yyear)\n -1\n else\n -2\n end) + \n dday)\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def geek_date(date)\n date.strftime(\"%Y-%m-%d\") \n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def mdes_formatted_date\n event_date.blank? ? true : only_date || event_date.match(MDES_DATE_FORMAT) ? true : false\n end",
"def date_str d\n Util::date(d)\n end",
"def date_format(date, options={})\n format = options[:format] || :long\n# puts 'date_format on ' + date.class.name + \" --- \" + date.inspect\n user ||= @current_user\n return '' if date.nil?\n date = Time.parse(date) if date.is_a?(String)\n if date.is_a?(Date) && !date.is_a?(DateTime) && !date.is_a?(Time)\n return date.to_formatted_s(format)\n end\n return date.to_local_s(user, :format=>format)\n end",
"def decorated_created_at\n\t created_at.to_date.to_s( :long )\n\t end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def longdate(d)\n d.strftime(\"%b %d\")\n end",
"def formatFullDate(date)\n date.strftime(\"%A, %B %d, %Y\")\n end",
"def to_s\n @date\n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end"
] |
[
"0.6249519",
"0.62080973",
"0.601992",
"0.59677535",
"0.5927565",
"0.5911778",
"0.5910613",
"0.5882393",
"0.5877799",
"0.5851",
"0.58409035",
"0.58233577",
"0.5756727",
"0.57434565",
"0.57348484",
"0.5720722",
"0.57056326",
"0.565787",
"0.56289965",
"0.56255573",
"0.5574238",
"0.5569935",
"0.5565372",
"0.5555788",
"0.5555788",
"0.55507356",
"0.55507356",
"0.55506355",
"0.5544668",
"0.5539394",
"0.5539394",
"0.5537889",
"0.5531063",
"0.55158234",
"0.5512657",
"0.5510335",
"0.5503572",
"0.5503572",
"0.54996705",
"0.5489267",
"0.5486888",
"0.548496",
"0.54846025",
"0.5482458",
"0.5480495",
"0.54538053",
"0.54490525",
"0.54334867",
"0.5433334",
"0.5433334",
"0.5428137",
"0.54244566",
"0.54215145",
"0.54204136",
"0.5411235",
"0.5408181",
"0.5406506",
"0.54020935",
"0.540033",
"0.53981775",
"0.5384414",
"0.53793746",
"0.53771067",
"0.53767216",
"0.536337",
"0.5354327",
"0.53522366",
"0.53449374",
"0.5342338",
"0.5340616",
"0.5340421",
"0.53364336",
"0.53244346",
"0.53207713",
"0.53202504",
"0.5317833",
"0.5317833",
"0.5317833",
"0.5317833",
"0.5317833",
"0.5308513",
"0.5305873",
"0.52995753",
"0.5293103",
"0.52907133",
"0.5290517",
"0.5285795",
"0.52847266",
"0.5281283",
"0.5281283",
"0.5281283",
"0.5275756",
"0.52747476",
"0.52737904",
"0.5271619",
"0.52655953",
"0.5265269",
"0.5262987",
"0.5256645",
"0.5252976"
] |
0.57560164
|
13
|
Formats a CarbonDate::Date with ten_thousand_years precision Returns: A humanreadable string representing the Date
|
def ten_thousand_years(date)
coarse_precision(date.year, 10e3.to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end",
"def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end",
"def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end",
"def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end",
"def format_date_nicely(date)\nend",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end",
"def born_date\n super.to_s(:long)\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def teen_driver_birth_date\n Chronic.parse('16 years ago').strftime('%m/%d/%Y')\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def humanize(dob)\n\t\t\tunit = @options[:humanize_unit]\n\t\t\tval = (((Time.now - dob) / SECONDS_IN[unit]).floor)\n\t\t\tsuffix = (val == 1) ? \"\" : \"s\"\n\t\t\t\"#{val} #{unit}#{suffix} old\"\n\t\tend",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def to_s\n \"FiscalYear #{ year }: #{ fd(days.first) } to #{ fd(days.last) }\"\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def teen_smart_birth_date\n Chronic.parse(\"#{rand(16..20)} years ago\").strftime('%m/%d/%Y')\n end",
"def display_str_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n return century_str_matches.to_s if century_str_matches\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n return \"#{($1.to_i + 1).ordinalize} century\"\n end\n end",
"def format_year(year)\n \"#{year}-#{year+1}\"\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def get_year_with_number\n date_receipt.strftime(\"%Y\") + \"-\" + sprintf( \"%03i\", receipt_num )\n end",
"def format_expiry_date(creditcard)\n month_str = \"%02d\" % creditcard.month\n if match = creditcard.year.to_s.match(/^\\d{2}(\\d{2})$/) \n year_str = \"%02d\" % match[1].to_i\n else \n year_str = \"%02d\" % creditcard.year\n end\n \"#{month_str}/#{year_str}\"\n end",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend",
"def pretty_date(date, options = {})\n options.reverse_merge! \\\n :title => date.iso8601,\n :format => :standard\n\n format = options.pluck(:format)\n\n content_tag :abbr, options do\n l(date, :format => format)\n end\n end",
"def to_date string\n \n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def decades() 10 * years end",
"def w_year\n @obj.date.strftime(\"%G\")\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def round( date )\n return date\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def date\n (@birth_date.to_time + 1_000_000_000).to_date\n end",
"def sortable_year_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n return $1 + '00' if $1.length == 2\n return '0' + $1 + '00' if $1.length == 1\n end\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n if century_str_matches\n yy = ($1.to_i - 1).to_s\n return yy + '00' if yy.length == 2\n return '0' + yy + '00' if yy.length == 1\n end\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def quoted_date(value) #:nodoc:\n if value.acts_like?(:time) && value.respond_to?(:usec)\n \"#{super}.#{sprintf(\"%06d\", value.usec)}\"\n else\n super\n end\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def process_century_date(ng_date_element)\n my_ng_date_element = ng_date_element.clone\n my_ng_date_element.content = begin\n orig_date_str = ng_date_element.text.strip\n # note: not calling DateParsing.display_str_for_century directly because non-year text is lost\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP) if orig_date_str\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n new_century_str = \"#{(century_matches[3].to_i + 1).ordinalize} century\"\n my_ng_date_element.content = \"#{century_matches[1]}#{new_century_str}#{century_matches[4]}\"\n else\n my_ng_date_element.content\n end\n rescue\n my_ng_date_element.content\n end\n my_ng_date_element\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def good_student_birth_date\n Chronic.parse(\"#{rand(16..24)} years ago\").strftime('%m/%d/%Y')\n end",
"def get_number_with_year\n receipt_num.to_s + \" / \" + get_date_receipt().strftime(\"%Y\")\n end",
"def date_str d\n Util::date(d)\n end",
"def format_timestamp(t)\n t.strftime('%s%9N')\n end",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def display_str_for_early_numeric\n return unless orig_date_str.match(EARLY_NUMERIC)\n # return 1 B.C. when the date is 0 since there is no 0 year\n return '1 B.C.' if orig_date_str == '0'\n # negative number becomes B.C.\n return \"#{orig_date_str[1..-1].to_i + 1} B.C.\" if orig_date_str =~ /^\\-/\n\n # remove leading 0s from early dates\n \"#{orig_date_str.to_i} A.D.\"\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def sortable_year_str_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n ($1.to_i - 1000).to_s if bc_matches\n end",
"def human_years \n age * DOG_YEARS\n end",
"def format_date(date)\n date.strftime '%Y-%m-%d'\n end",
"def formatted_date\n \tobject.created_at.strftime(\"%R - %B %e, %Y \")\n end"
] |
[
"0.6480022",
"0.62412304",
"0.6012005",
"0.59666866",
"0.5856101",
"0.5848344",
"0.5779537",
"0.5720695",
"0.5717529",
"0.5710835",
"0.5669659",
"0.565364",
"0.56508756",
"0.56508756",
"0.56446445",
"0.56200486",
"0.55205345",
"0.55137295",
"0.5507825",
"0.54464793",
"0.543618",
"0.543618",
"0.5425195",
"0.5391764",
"0.53773755",
"0.53726095",
"0.5371673",
"0.5365106",
"0.53452307",
"0.53416735",
"0.5340363",
"0.53358835",
"0.53350526",
"0.5325678",
"0.53223413",
"0.53197885",
"0.5316028",
"0.5314014",
"0.5314014",
"0.5308519",
"0.5295135",
"0.52876264",
"0.5266528",
"0.5266108",
"0.52581185",
"0.5255542",
"0.52507055",
"0.5238492",
"0.5236064",
"0.52347726",
"0.52297044",
"0.5224682",
"0.52235526",
"0.5222597",
"0.5219459",
"0.5218061",
"0.52134466",
"0.5210314",
"0.52016336",
"0.5199274",
"0.5199274",
"0.5197037",
"0.51894337",
"0.51841825",
"0.51814216",
"0.51763016",
"0.517408",
"0.5168522",
"0.5161112",
"0.5160578",
"0.5159882",
"0.51591194",
"0.5158537",
"0.5149144",
"0.5136725",
"0.5134728",
"0.512893",
"0.51288414",
"0.5126314",
"0.51220727",
"0.5115296",
"0.5115296",
"0.5115296",
"0.5115296",
"0.5115296",
"0.5115157",
"0.5109877",
"0.51032287",
"0.5096645",
"0.50929534",
"0.5092145",
"0.5091429",
"0.50882494",
"0.5081846",
"0.5078018",
"0.507514",
"0.5073794",
"0.50670594",
"0.50660807",
"0.5065505"
] |
0.681807
|
0
|
Formats a CarbonDate::Date with hundred_thousand_years precision Returns: A humanreadable string representing the Date
|
def hundred_thousand_years(date)
coarse_precision(date.year, 100e3.to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end",
"def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end",
"def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end",
"def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def format_date_nicely(date)\nend",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def humanize(dob)\n\t\t\tunit = @options[:humanize_unit]\n\t\t\tval = (((Time.now - dob) / SECONDS_IN[unit]).floor)\n\t\t\tsuffix = (val == 1) ? \"\" : \"s\"\n\t\t\t\"#{val} #{unit}#{suffix} old\"\n\t\tend",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def born_date\n super.to_s(:long)\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def teen_driver_birth_date\n Chronic.parse('16 years ago').strftime('%m/%d/%Y')\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def display_str_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n return century_str_matches.to_s if century_str_matches\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n return \"#{($1.to_i + 1).ordinalize} century\"\n end\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def decade(date)\n d = ((date.year.abs.to_i / 10) * 10).to_s + 's'\n return [d, BCE_SUFFIX].join(' ') if (date.year <= -1)\n d\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def century(number)\n century_int = ''\n suffix_str = ''\n\n century_int = (number / 100) + 1\n century_int -= 1 if number % 100 == 0\n suffix_str = suffix(century_int)\n\n century_int.to_s + suffix_str\nend",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def format_year(year)\n \"#{year}-#{year+1}\"\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def century(date)\n c = ((date.year.abs.to_i / 100) + 1).ordinalize + ' century'\n return [c, BCE_SUFFIX].join(' ') if (date.year <= -1)\n c\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def sortable_year_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n return $1 + '00' if $1.length == 2\n return '0' + $1 + '00' if $1.length == 1\n end\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n if century_str_matches\n yy = ($1.to_i - 1).to_s\n return yy + '00' if yy.length == 2\n return '0' + yy + '00' if yy.length == 1\n end\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def spelled_out_for_date(date)\n %w[%B %b].map { |month| date.strftime(\"#{month} %Y\") }\n end",
"def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end",
"def ordinalize(date)\n \"#{date.strftime('%b %-d')}#{ordinal_suffix(date)}, #{date.strftime('%Y')}\"\n end",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def nice_dob\n\t\t@nice_dob = @dob.strftime(\"%A the #{@dob.day.ordinalize} %B %Y\")\n\tend",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def century(year)\n century = (year.to_f / 100).ceil.to_s\n suffix(century)\nend",
"def to_s\n \"FiscalYear #{ year }: #{ fd(days.first) } to #{ fd(days.last) }\"\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def teen_smart_birth_date\n Chronic.parse(\"#{rand(16..20)} years ago\").strftime('%m/%d/%Y')\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def sortable_year_str_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n ($1.to_i - 1000).to_s if bc_matches\n end",
"def decades() 10 * years end",
"def w_year\n @obj.date.strftime(\"%G\")\n end",
"def round( date )\n return date\n end",
"def century(year)\n num = (year - 1) / 100 + 1\n century = num.to_s + suffix(num)\nend",
"def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend",
"def display_str_for_early_numeric\n return unless orig_date_str.match(EARLY_NUMERIC)\n # return 1 B.C. when the date is 0 since there is no 0 year\n return '1 B.C.' if orig_date_str == '0'\n # negative number becomes B.C.\n return \"#{orig_date_str[1..-1].to_i + 1} B.C.\" if orig_date_str =~ /^\\-/\n\n # remove leading 0s from early dates\n \"#{orig_date_str.to_i} A.D.\"\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def human_years \n age * DOG_YEARS\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def human_date(date, optional_text= nil)\n if optional_text\n date.strftime(\"#{optional_text}\"+\" %d.%m.%Y\")\n else\n date.strftime(\"%d.%m.%Y\")\n end\n end",
"def thousands_string\n if display_thousands\n \".#{pad(thousands, 3)}\"\n elsif display_hundreds\n \".#{pad((thousands / 10.0).round, 2)}\"\n else\n \"\"\n end\n end",
"def to_s\n fy = first.year.to_s\n end_year = last.year\n fy += \"-\" + end_year.to_s unless first.year == end_year\n fy\n end",
"def century(integer)\n century_number = integer / 100 + 1\n century_number -= 1 if integer % 100 == 0\n century_number.to_s + century_suffix(century_number)\nend",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def century(year)\n hundreds = ( (year + 99) / 100 ).to_s\n if hundreds[-2] == '1'\n suffix = 'th'\n else\n last_digit = hundreds[-1]\n case last_digit\n when '1' then suffix = 'st'\n when '2' then suffix = 'nd'\n when '3' then suffix = 'rd'\n else suffix = 'th'\n end\n end\n hundreds + suffix\nend",
"def year_name(number)\n if year_format_lambda = @options[:year_format]\n year_format_lambda.call(number)\n else\n number\n end\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def get_year_with_number\n date_receipt.strftime(\"%Y\") + \"-\" + sprintf( \"%03i\", receipt_num )\n end",
"def format_date(date)\n date.strftime '%d-%m-%Y'\n end"
] |
[
"0.65144795",
"0.6489899",
"0.6168684",
"0.6153184",
"0.6072605",
"0.60651904",
"0.60636854",
"0.60636854",
"0.60246164",
"0.5978676",
"0.5938752",
"0.58899736",
"0.5809043",
"0.5778706",
"0.57681113",
"0.57350665",
"0.57097524",
"0.57077795",
"0.56959915",
"0.5690208",
"0.5670169",
"0.5666612",
"0.56615746",
"0.5651561",
"0.56229013",
"0.56112534",
"0.56112534",
"0.55972487",
"0.5580168",
"0.5559789",
"0.55529976",
"0.5550729",
"0.55435073",
"0.55435073",
"0.5523967",
"0.5521908",
"0.5510783",
"0.5507592",
"0.54647803",
"0.54603684",
"0.54394037",
"0.54394037",
"0.54394037",
"0.54394037",
"0.54394037",
"0.5430349",
"0.5429578",
"0.54233646",
"0.5414651",
"0.5413719",
"0.5406562",
"0.54032946",
"0.53973514",
"0.539717",
"0.5394054",
"0.53887606",
"0.5384992",
"0.5384078",
"0.53776795",
"0.53662956",
"0.5351081",
"0.5348142",
"0.5347782",
"0.5343697",
"0.5342535",
"0.5338818",
"0.5335136",
"0.5332288",
"0.53295004",
"0.53250957",
"0.53250957",
"0.53250957",
"0.5322007",
"0.531443",
"0.53079396",
"0.5303294",
"0.5302225",
"0.5302095",
"0.5301396",
"0.5300485",
"0.5300292",
"0.52924705",
"0.5287338",
"0.52857685",
"0.5282831",
"0.527909",
"0.5277959",
"0.5272638",
"0.52623254",
"0.526175",
"0.5257393",
"0.52562815",
"0.5252279",
"0.5251718",
"0.52498156",
"0.5248952",
"0.5247384",
"0.5241118",
"0.5239525",
"0.5228786"
] |
0.6821243
|
0
|
Formats a CarbonDate::Date with million_years precision Returns: A humanreadable string representing the Date
|
def million_years(date)
coarse_precision(date.year, 1e6.to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end",
"def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end",
"def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end",
"def format_date_nicely(date)\nend",
"def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def born_date\n super.to_s(:long)\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def date\n (@birth_date.to_time + 1_000_000_000).to_date\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def dmy_date(date)\n Time.gm(date.year, date.month, date.day)\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def to_fixed(g_date = self)\n mmonth = g_date.month\n dday = g_date.day\n yyear = g_date.year\n ((epoch - 1) + \n (365 * (yyear - 1)) + \n quotient(yyear - 1, 4) - \n quotient(yyear - 1, 100) + \n quotient(yyear - 1, 400) + \n quotient((367 * mmonth) - 362, 12) +\n (if mmonth <= 2\n 0\n elsif leap_year?(yyear)\n -1\n else\n -2\n end) + \n dday)\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def years\n self.to_i * 31_557_600\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def to_date string\n \n end",
"def humanize(dob)\n\t\t\tunit = @options[:humanize_unit]\n\t\t\tval = (((Time.now - dob) / SECONDS_IN[unit]).floor)\n\t\t\tsuffix = (val == 1) ? \"\" : \"s\"\n\t\t\t\"#{val} #{unit}#{suffix} old\"\n\t\tend",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def teen_smart_birth_date\n Chronic.parse(\"#{rand(16..20)} years ago\").strftime('%m/%d/%Y')\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def to_fixed(fr_date = self)\n mmonth = fr_date.month\n dday = fr_date.day\n yyear = fr_date.year\n new_year = new_year_on_or_before((epoch + 180 + MEAN_TROPICAL_YEAR * (yyear - 1)).floor)\n new_year - 1 + 30 * (mmonth - 1) + dday\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def teen_driver_birth_date\n Chronic.parse('16 years ago').strftime('%m/%d/%Y')\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def human_years \n age * DOG_YEARS\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def to_fixed(j_date = self)\n mmonth = j_date.month\n dday = j_date.day\n yyear = j_date.year\n y = yyear < 0 ? yyear + 1 : yyear\n (epoch - 1 + (365 * (y - 1)) + quotient(y - 1, 4) + quotient(367 * mmonth - 362, 12) +\n (if mmonth <= 2\n 0\n elsif Julian::Year[yyear].leap_year?\n -1\n else\n -2\n end) +\n dday)\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def round( date )\n return date\n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def decades() 10 * years end",
"def normalized\n expanded = length == 2 ? \"20#{self}\".to_i : self.to_i # Assume no 3-digit years\n expanded >= Time.now.year ? expanded : Time.now.year\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def normalize_fuzzy_date(date_str)\n if date_str.present?\n date_str = date_str.gsub(\"-\", \"\")\n if date_str.length < 8\n pad = 8 - date_str.length\n date_str += \"0\" * pad\n end\n end\n date_str\n end",
"def date\n (birthday.to_time + 10**9).to_date\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def good_student_birth_date\n Chronic.parse(\"#{rand(16..24)} years ago\").strftime('%m/%d/%Y')\n end",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def human_years\n age * DOG_YEARS\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def mdy(date)\n\t\t( date.nil? )?' ':date.strftime(\"%m/%d/%Y\")\n\tend",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def w_year\n @obj.date.strftime(\"%G\")\n end",
"def mongoize\n \"#{format('%04d', year)}-#{format('%02d', month)}-#{format('%02d', day)}\"\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend"
] |
[
"0.64051497",
"0.63893443",
"0.62808996",
"0.6013068",
"0.5954019",
"0.59120136",
"0.5871082",
"0.58656216",
"0.5839477",
"0.58277667",
"0.58230555",
"0.5721606",
"0.57044834",
"0.57044834",
"0.56823957",
"0.56441736",
"0.56210005",
"0.56068146",
"0.56017363",
"0.55892205",
"0.5583867",
"0.5569879",
"0.55648786",
"0.5562076",
"0.5525766",
"0.54762596",
"0.5470328",
"0.54616463",
"0.5450508",
"0.5441967",
"0.5441967",
"0.5426636",
"0.54230237",
"0.5417354",
"0.5416718",
"0.5416718",
"0.541453",
"0.5412692",
"0.5408698",
"0.5399339",
"0.53868425",
"0.5381271",
"0.5375595",
"0.53644735",
"0.5358008",
"0.53436476",
"0.5337463",
"0.5332981",
"0.53259635",
"0.5318589",
"0.53166854",
"0.5303337",
"0.5302416",
"0.53004825",
"0.52984756",
"0.5296514",
"0.5282554",
"0.5281649",
"0.5270787",
"0.52634",
"0.52626693",
"0.52591676",
"0.52591676",
"0.52591676",
"0.52548707",
"0.5253792",
"0.5253494",
"0.5253494",
"0.5253494",
"0.5253494",
"0.5253494",
"0.52529085",
"0.5230548",
"0.5228121",
"0.52268404",
"0.5218163",
"0.5216344",
"0.5211441",
"0.5211441",
"0.52061933",
"0.5203877",
"0.5201504",
"0.5193565",
"0.51932997",
"0.5181447",
"0.5173266",
"0.516972",
"0.5166562",
"0.5165514",
"0.51589966",
"0.5157727",
"0.5157727",
"0.5157727",
"0.5155406",
"0.5154646",
"0.5147233",
"0.51422447",
"0.5138467",
"0.5131786",
"0.5131553"
] |
0.65519065
|
0
|
Formats a CarbonDate::Date with ten_million_years precision Returns: A humanreadable string representing the Date
|
def ten_million_years(date)
coarse_precision(date.year, 10e6.to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end",
"def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end",
"def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end",
"def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end",
"def format_date_nicely(date)\nend",
"def born_date\n super.to_s(:long)\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def teen_driver_birth_date\n Chronic.parse('16 years ago').strftime('%m/%d/%Y')\n end",
"def date\n (@birth_date.to_time + 1_000_000_000).to_date\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def to_date string\n \n end",
"def teen_smart_birth_date\n Chronic.parse(\"#{rand(16..20)} years ago\").strftime('%m/%d/%Y')\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def date\n (birthday.to_time + 10**9).to_date\n end",
"def print_readable_date(date)\n\t\ttime_ago_in_words(date)\n\tend",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def humanize(dob)\n\t\t\tunit = @options[:humanize_unit]\n\t\t\tval = (((Time.now - dob) / SECONDS_IN[unit]).floor)\n\t\t\tsuffix = (val == 1) ? \"\" : \"s\"\n\t\t\t\"#{val} #{unit}#{suffix} old\"\n\t\tend",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_str d\n Util::date(d)\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def decades() 10 * years end",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def pretty_date(date, options = {})\n options.reverse_merge! \\\n :title => date.iso8601,\n :format => :standard\n\n format = options.pluck(:format)\n\n content_tag :abbr, options do\n l(date, :format => format)\n end\n end",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def decorated_created_at\n\t created_at.to_date.to_s( :long )\n\t end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def normalize_fuzzy_date(date_str)\n if date_str.present?\n date_str = date_str.gsub(\"-\", \"\")\n if date_str.length < 8\n pad = 8 - date_str.length\n date_str += \"0\" * pad\n end\n end\n date_str\n end",
"def format_expiry_date(creditcard)\n month_str = \"%02d\" % creditcard.month\n if match = creditcard.year.to_s.match(/^\\d{2}(\\d{2})$/) \n year_str = \"%02d\" % match[1].to_i\n else \n year_str = \"%02d\" % creditcard.year\n end\n \"#{month_str}/#{year_str}\"\n end",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def printHTMLDateLong(tobj)\n return alStrftime(tobj,'%B %d, %Y')\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def quoted_date(value) #:nodoc:\n if value.acts_like?(:time) && value.respond_to?(:usec)\n \"#{super}.#{sprintf(\"%06d\", value.usec)}\"\n else\n super\n end\n end",
"def good_student_birth_date\n Chronic.parse(\"#{rand(16..24)} years ago\").strftime('%m/%d/%Y')\n end",
"def watch_birthdate\n birthdate.to_s(:short_date)\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def round( date )\n return date\n end",
"def formatted_date\n Date.strptime(date, \"%m/%d/%Y\")\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def to_s\n \"#{@month}/#{@day}/#{@year}\"\n end",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def formatted_created_at\n self.created_at.to_date.to_s(:long)\nend",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def as_readable_date\n strftime \"%b %e, %Y\"\n end"
] |
[
"0.6353445",
"0.6072817",
"0.6047292",
"0.6042898",
"0.5839487",
"0.5815037",
"0.57690495",
"0.57598335",
"0.5718243",
"0.5715554",
"0.56648076",
"0.56621873",
"0.5647103",
"0.5595492",
"0.5591696",
"0.5591696",
"0.5563381",
"0.5522932",
"0.5522932",
"0.5477907",
"0.54554003",
"0.5402629",
"0.53850657",
"0.53835696",
"0.5379669",
"0.5365937",
"0.5360979",
"0.5359769",
"0.5358833",
"0.5339054",
"0.53321576",
"0.53235185",
"0.530327",
"0.5302507",
"0.529518",
"0.52926797",
"0.52914876",
"0.5280786",
"0.52807295",
"0.5278759",
"0.5264094",
"0.52576596",
"0.52548957",
"0.5232885",
"0.52286834",
"0.5219416",
"0.5219416",
"0.5218331",
"0.5214627",
"0.5208276",
"0.52038884",
"0.5203561",
"0.51981974",
"0.51912254",
"0.51845556",
"0.51791817",
"0.51748645",
"0.51748645",
"0.51748645",
"0.51748645",
"0.51748645",
"0.51681876",
"0.51646906",
"0.51646906",
"0.51631165",
"0.51592404",
"0.5148025",
"0.5141108",
"0.5136844",
"0.512625",
"0.51233506",
"0.512329",
"0.512165",
"0.51165384",
"0.51116776",
"0.5102435",
"0.50986475",
"0.5095092",
"0.50914276",
"0.50914276",
"0.50914276",
"0.5087793",
"0.5078104",
"0.5061715",
"0.5058202",
"0.50551164",
"0.50475043",
"0.504431",
"0.5043091",
"0.5039893",
"0.5039478",
"0.5033293",
"0.5031842",
"0.5031494",
"0.50306827",
"0.5024481",
"0.50224966",
"0.5015895",
"0.5015862",
"0.5015559"
] |
0.6582434
|
0
|
Formats a CarbonDate::Date with hundred_million_years precision Returns: A humanreadable string representing the Date
|
def hundred_million_years(date)
coarse_precision(date.year, 100e6.to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end",
"def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end",
"def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end",
"def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end",
"def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end",
"def format_date_nicely(date)\nend",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def born_date\n super.to_s(:long)\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def humanize(dob)\n\t\t\tunit = @options[:humanize_unit]\n\t\t\tval = (((Time.now - dob) / SECONDS_IN[unit]).floor)\n\t\t\tsuffix = (val == 1) ? \"\" : \"s\"\n\t\t\t\"#{val} #{unit}#{suffix} old\"\n\t\tend",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def teen_driver_birth_date\n Chronic.parse('16 years ago').strftime('%m/%d/%Y')\n end",
"def date\n (@birth_date.to_time + 1_000_000_000).to_date\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def spelled_out_for_date(date)\n %w[%B %b].map { |month| date.strftime(\"#{month} %Y\") }\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def decade(date)\n d = ((date.year.abs.to_i / 10) * 10).to_s + 's'\n return [d, BCE_SUFFIX].join(' ') if (date.year <= -1)\n d\n end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def teen_smart_birth_date\n Chronic.parse(\"#{rand(16..20)} years ago\").strftime('%m/%d/%Y')\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def decades() 10 * years end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def to_date string\n \n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def stringify_date(date, month_type, type = nil, style = nil)\n return date if date.to_s.empty?\n\n time = time(date)\n if type == \"ordinal\"\n day = time.day\n ordinal_day = \"#{day}#{ordinal(day)}\"\n return time.strftime(\"#{month_type} #{ordinal_day}, %Y\") if style == \"US\"\n\n return time.strftime(\"#{ordinal_day} #{month_type} %Y\")\n end\n time.strftime(\"%d #{month_type} %Y\")\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def years\n self.to_i * 31_557_600\n end",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def round( date )\n return date\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def to_fixed(g_date = self)\n mmonth = g_date.month\n dday = g_date.day\n yyear = g_date.year\n ((epoch - 1) + \n (365 * (yyear - 1)) + \n quotient(yyear - 1, 4) - \n quotient(yyear - 1, 100) + \n quotient(yyear - 1, 400) + \n quotient((367 * mmonth) - 362, 12) +\n (if mmonth <= 2\n 0\n elsif leap_year?(yyear)\n -1\n else\n -2\n end) + \n dday)\n end",
"def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def to_fixed(fr_date = self)\n mmonth = fr_date.month\n dday = fr_date.day\n yyear = fr_date.year\n new_year = new_year_on_or_before((epoch + 180 + MEAN_TROPICAL_YEAR * (yyear - 1)).floor)\n new_year - 1 + 30 * (mmonth - 1) + dday\n end",
"def good_student_birth_date\n Chronic.parse(\"#{rand(16..24)} years ago\").strftime('%m/%d/%Y')\n end",
"def display_str_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n return century_str_matches.to_s if century_str_matches\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n return \"#{($1.to_i + 1).ordinalize} century\"\n end\n end",
"def century(date)\n c = ((date.year.abs.to_i / 100) + 1).ordinalize + ' century'\n return [c, BCE_SUFFIX].join(' ') if (date.year <= -1)\n c\n end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def mongoize\n \"#{format('%04d', year)}-#{format('%02d', month)}-#{format('%02d', day)}\"\n end",
"def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end",
"def human_years \n age * DOG_YEARS\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def normalize_fuzzy_date(date_str)\n if date_str.present?\n date_str = date_str.gsub(\"-\", \"\")\n if date_str.length < 8\n pad = 8 - date_str.length\n date_str += \"0\" * pad\n end\n end\n date_str\n end",
"def longdate(d)\n d.strftime(\"%b %d\")\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def nice_dob\n\t\t@nice_dob = @dob.strftime(\"%A the #{@dob.day.ordinalize} %B %Y\")\n\tend",
"def date\n (birthday.to_time + 10**9).to_date\n end",
"def human_date(date, optional_text= nil)\n if optional_text\n date.strftime(\"#{optional_text}\"+\" %d.%m.%Y\")\n else\n date.strftime(\"%d.%m.%Y\")\n end\n end",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend"
] |
[
"0.6489859",
"0.6457484",
"0.6398476",
"0.639723",
"0.6288928",
"0.6007059",
"0.5962666",
"0.5959947",
"0.5928867",
"0.58949167",
"0.5890696",
"0.5890696",
"0.58042276",
"0.57296354",
"0.56888074",
"0.56431854",
"0.5635764",
"0.562886",
"0.56057197",
"0.5601694",
"0.5569729",
"0.5559465",
"0.5548831",
"0.5548387",
"0.55197245",
"0.55150074",
"0.5505307",
"0.5502711",
"0.5501322",
"0.5473712",
"0.5472046",
"0.5469979",
"0.5463265",
"0.5453982",
"0.54462",
"0.5431306",
"0.5431306",
"0.5431306",
"0.5431306",
"0.5431306",
"0.5426569",
"0.54235893",
"0.54235893",
"0.54180014",
"0.54046756",
"0.5400002",
"0.5389263",
"0.53815895",
"0.5378062",
"0.5378062",
"0.53740674",
"0.53706294",
"0.53656965",
"0.53656965",
"0.53650916",
"0.53551286",
"0.5354561",
"0.53349584",
"0.53286105",
"0.5319502",
"0.53082025",
"0.5303623",
"0.52963597",
"0.52951217",
"0.52951217",
"0.52951217",
"0.52837175",
"0.52835697",
"0.5282749",
"0.5272519",
"0.5262935",
"0.5261189",
"0.52552325",
"0.5244631",
"0.52436095",
"0.52422374",
"0.52345973",
"0.5231032",
"0.52289015",
"0.52280134",
"0.5212888",
"0.52113795",
"0.52111536",
"0.5209849",
"0.5189704",
"0.51843387",
"0.518291",
"0.51782507",
"0.51686984",
"0.516454",
"0.51625425",
"0.5160948",
"0.5160274",
"0.5158867",
"0.51585305",
"0.5158241",
"0.5157606",
"0.51566803",
"0.5149618",
"0.5144777"
] |
0.6697717
|
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.